Hello,

In case you interested to target your F#/OCaml code to JVM, you can study followed projects:
Ja.NET - JDK for .NET
OCaml-Java - your OCaml programs will be compiled to JVM bytecode

By on 2/19/2009 10:09 PM ()

Have you looked at Scala [1]? I think this is currently the most advance functional programming language for the JVM.

F# has been designed to be a functional programming language for the CLI, so I can't help thinking that a port will not be completely straight forward. Not least of the is problems is that F# is currently written in F#, so even if you were just change the back end to output java byte codes then you still need a version of the CLI to be installed to be able to run the "F# for JVM" compiler.

Cheers,

Rob

[1] [link:www.scala-lang.org]

By on 2/18/2009 2:39 AM ()

Wuuldn't it be a standard compiler bootstrapping technique to then compile the F# compiler using the F# to JVM compiler. Presto, a "native" F# to JVM compiler, running on the JVM.There may be interesting info on [link:flyingfrogblog.blogspot.com] especially on the comments to the entry of 25th of december 2008, where some issues with the JVM are discussed for porting F#/Ocaml like languages.Kurt

By on 2/18/2009 5:03 AM ()

It's a good point, but doesn't bootstrapping involve quite a bit more work than simply changing the byte code generation? To bootstrap you also have to ensure your not using any libraries in the CLR that aren't also available in JVM. I have no idea how difficult this would be, but it doesn't sound easy to me.

Rob

By on 2/18/2009 5:27 AM ()

Also I guess the points I'm trying to make in around about sort of way is that there might be easier starting points, like how about adding more F# like features to scalar? or bootstrapping from ocaml like F# did originally?

By on 2/18/2009 5:31 AM ()

Robert,Yes, this is un undertaking that shouldn't be taken lightly, and I'd agree that you'd need some very specific goals to warrant the effort. I don't really see much point either, as you say, scala is an option for functional/OO programming, if it's platform independence you're after there's mono, I don't see a compelling reason in the Java library space (on the contrary...), seems like the JVM is not really up to it,  and so on.On the other hand, you could do it for fun, not for profit. In that case, go for it :) and my comment was more targeted to that sort of scenario.Kurt

By on 2/18/2009 6:16 AM ()

Thanks for your responses so far. I try to reply to all at once...

Robert: "Have you looked at Scala"

Yes, I did. And so did others. There are several aspects of Scala I don't like. Starting with syntax issues (e.g. no toplevel functions), to type checking and other things (cf. [link:groups.google.com]

Robert: "To bootstrap you also have to ensure your not using any libraries in the CLR that aren't also available in JVM."

True. I would expect a partial rewrite of the runtime support to use classes available on the JVM. There are nice functional collections classes based on "Purely

functional data structures"

([link:www.cs.cmu.edu] and used in Clojure

(cf.

[link:code.google.com] which can be used for the implementation on lists, sets maps and so on. Initially though the compiler can be hosted on .NET producing JVM bytecode which is executed on the JVM, so only client code must be aware of not using .NET classes, but Java classes. Long term goal would be to change the internal compiler dependencies on .NET to use Java classes instead. I am not sure how much of .NET is used by the compiler alone, hence this forum post.

Kurt: "I don't really see much point either, as you say, scala is an option for functional/OO programming, if it's platform independence you're after there's mono, I don't see a compelling reason in the Java library space (on the contrary...), seems like the JVM is not really up to it, and so on."

Well this would be no commercial endeavour so I don't need a business case or anything like this. Second I don't think Scala is the answer to the need of statically typed functional languages on the JVM. Mono is not an option because of its relatively weak implementation. F# doesn't even run properly on mono (cf. [link:bugzilla.novell.com] Also TCO is weak in mono too (cf. [link:flyingfrogblog.blogspot.com] Finally the JVM and .NET share more similarities than differences. They have the same object model and there are many good libraries available for it. And its ubiquitous with top performance and nice tool support. So if the JVm is not an attractive target to host languages, nothing is. If Microsoft would open source the CLR, then things might change but this is less likely than the JVM getting proper TCO support. Also an F# running on the JVM wouldn't be the first functional language there. Clojure is very well done (but dynamically typed) and in fact there is a CLR port of Clojure underway. Don't underestimate the value of languages streching multiple platforms.

Regardless, I didn't want to defend my motives but rather I was hoping for some guidance in how to approach this porting effort.

By on 2/18/2009 11:11 AM ()

Finally the JVM and .NET share more similarities than differences. They have the same object model

Ah, but they do not. And that is a problem, because quite a bit of F#-the-language (and not the particular compiler & implementation) is centered around the .NET object model.

At best, you could design a new language that would be to JVM what F# is to .NET. Probably with mostly the same ML-like language core, but the object model would have to be reworked, and I'd expect that implementation techniques would have to be different in many cases (given that JVM doesn't have value types, for example).

By on 4/2/2009 5:56 PM ()

I agree, having something similar to F# will be fantastic! I asked about F# on the JVM on these forums long before the productization announcement, but received an enthusiastic response. It makes sense since Don works for MS.

I have also looked at Scala. Despite my attempts to like it (I bought the book!), it just doesn't sit well. It is too verbose, seems to have unnecessary complexity, etc.

Again, it is probably not a good idea to try "port" F# to the JVM. Rather, like clojure, there should be an *ML for the JVM. Pragmatically designed and implemented with a view towards programmers in the industry rather than academic researchers. Obviously this ML-JVM should have computational expressions, first class events, etc. :)

By on 4/2/2009 10:33 AM ()

Again, it is probably not a good idea to try "port" F# to the JVM. Rather, like clojure, there should be an *ML for the JVM. Pragmatically designed and implemented with a view towards programmers in the industry rather than academic researchers. Obviously this ML-JVM should have computational expressions, first class events, etc. :)

Yes, probably. In the meantime I have settled on Clojure which is just fantastic. W.r.t static typing I would like to see something like dialyzer which is a static analysis tool for Erlang. Otherwise I am fine with the dynamic typing and do not actually miss an ML anymore.

By on 4/2/2009 11:31 AM ()

Mono is not an option because of its relatively weak implementation. F#

doesn't even run properly on mono (cf.

[link:bugzilla.novell.com] Also TCO is weak

in mono too (cf.

[link:flyingfrogblog.blogspot.com]

No offense, but saying that F# doesn't run properly on Mono is a bit

harsh. The bug in your report does not happen if you compile it with

fsc instead of running it with fsi. So far that has been my experience with

F# and Mono. Compiled programs run fine, but fsi is buggy on Mono. It

seems that fsi's use of reflection does not always go well on Mono.

Mono has a similar runtime interpreter for C# so it is able to do those

things.

By on 2/18/2009 1:15 PM ()

Mono is not an option because of its relatively weak implementation. F#

doesn't even run properly on mono (cf.

[link:bugzilla.novell.com] Also TCO is weak

in mono too (cf.

[link:flyingfrogblog.blogspot.com]

No offense, but saying that F# doesn't run properly on Mono is a bit

harsh...

On the contrary, I think it is a gross understatement. I have tried to get F# running on Mono on several occasions, firstly because it would be very useful to me and secondly because our customers have complained about F# not working correctly only when they are using it under Mono.

FSI has never worked and FSC rarely works correctly. I've seen correct F# programs leak heap space until all available memory is exhausted within seconds. I've seen correct F# programs leak stack space so they die with a stack overflow within a millisecond. Most programs cannot be run because the required libraries are not available under Mono, e.g. they never even aspired to provide .NET 3 compatibility. Some bugs in F# were showstoppers only on Mono, e.g. you cannot even derive from WinForms text box in F# on Mono. And so on.

Moreover, I even demonstrated the problems to the Mono developers only to receive a series of incorrect descriptions and lame excuses in response. IMHO, the situation with the current Mono developers is so dire that, when I was asked if it would be worth Novell throwing another million dollars at Mono development, I said "no". When you've got a code base that rotten your only viable option is to rewrite it. If you want it rewritten well, you need a new development team. If you want a decent new development team then you need to replace management as well, preferably with people who won't just employ their friends called lupus and zoltan.

Suffice to say, I do not have much faith in the future of the Mono project...

By on 4/2/2009 4:43 AM ()

Another option might be to create a F# grammar first (possibly with ANTLR) and doing naive bytecode generation (with the help of ASM). Finally maybe the typechecker can be integrated then. I.e. only type checking would be reused.

By on 2/18/2009 12:00 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper