* [Caml-list] A js_of_ocaml equivalent for the JVM? @ 2012-03-09 17:12 Philippe Veber 2012-03-09 17:45 ` Johan Grande 0 siblings, 1 reply; 5+ messages in thread From: Philippe Veber @ 2012-03-09 17:12 UTC (permalink / raw) To: caml users [-- Attachment #1: Type: text/plain, Size: 778 bytes --] Dear camlers, I used js_of_ocaml several times and was really stunned of how clever (notably because writing interfaces boils down to writing types) and efficient this approach is. Would a similar thing work for the JVM, that is a compiler from ocaml bytecode to java bytecode? I guess it wouldn't provide a full interoperability with java, in the sense that creating or extending classes may not be possible (well, why not after all?). However, being able to run an ocaml program on the JVM reusing existing java libraries would be so useful already! Are there known obstacles to this? Has anyone tried something in this direction? Would there be a chance to support multicore programming that way? I hope these are not silly questions (sorry if they are!) Best, Philippe. [-- Attachment #2: Type: text/html, Size: 818 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] A js_of_ocaml equivalent for the JVM? 2012-03-09 17:12 [Caml-list] A js_of_ocaml equivalent for the JVM? Philippe Veber @ 2012-03-09 17:45 ` Johan Grande 2012-03-09 18:05 ` forum 0 siblings, 1 reply; 5+ messages in thread From: Johan Grande @ 2012-03-09 17:45 UTC (permalink / raw) To: Philippe Veber; +Cc: caml users Le 09/03/2012 18:12, Philippe Veber a écrit : > Dear camlers, > I used js_of_ocaml several times and was really stunned of how clever > (notably because writing interfaces boils down to writing types) and > efficient this approach is. Would a similar thing work for the JVM, that > is a compiler from ocaml bytecode to java bytecode? I guess it wouldn't > provide a full interoperability with java, in the sense that creating or > extending classes may not be possible (well, why not after all?). > However, being able to run an ocaml program on the JVM reusing existing > java libraries would be so useful already! > > Are there known obstacles to this? Has anyone tried something in this > direction? Would there be a chance to support multicore programming that > way? I hope these are not silly questions (sorry if they are!) http://ocamljava.x9c.fr (I never tried it myself.) -- Johan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] A js_of_ocaml equivalent for the JVM? 2012-03-09 17:45 ` Johan Grande @ 2012-03-09 18:05 ` forum 2012-03-12 16:05 ` Philippe Veber 2012-03-13 16:55 ` Richard W.M. Jones 0 siblings, 2 replies; 5+ messages in thread From: forum @ 2012-03-09 18:05 UTC (permalink / raw) To: caml users; +Cc: Xavier Clerc Le 9 mars 2012 à 18:45, Johan Grande a écrit : > Le 09/03/2012 18:12, Philippe Veber a écrit : >> Dear camlers, >> I used js_of_ocaml several times and was really stunned of how clever >> (notably because writing interfaces boils down to writing types) and >> efficient this approach is. Would a similar thing work for the JVM, that >> is a compiler from ocaml bytecode to java bytecode? It is not easy to envision such a tool on the JVM, because of the current restrictions imposed on Java bytecode. As an example, the size of a method is currently limited to 64Ko, which is clearly way too small for non trivial programs. >> I guess it wouldn't >> provide a full interoperability with java, in the sense that creating or >> extending classes may not be possible (well, why not after all?). >> However, being able to run an ocaml program on the JVM reusing existing >> java libraries would be so useful already! I am currently working on this for OCaml-Java (see below). >> Are there known obstacles to this? Has anyone tried something in this >> direction? Well, no real obstacle as OCaml-Java showed. However, OCaml-Java 1.x is still a bare proof of concept due to both poor design choices and JVM limitations. But then came Java 1.7 and some limitations were removed (e. g. a garbage collector better suited to functional languages, and an implementation of method handles). OCaml-Java has been largely rewritten and now exhibit acceptable performances. >> Would there be a chance to support multicore programming that >> way? Yes, it is actually working. But not released yet. Starting from vanilla OCaml, you "only" need two things: 1/ have a reentrant runtime; 2/ have a parallel garbage collector. OCaml-Java implements the former, while all modern JVMs provide the latter. So, basically, it just works. The great difficulty is then to provide the good abstractions to make the life of the programmer as easy as possible. I mean: who would like to program with locks? >> I hope these are not silly questions (sorry if they are!) > > http://ocamljava.x9c.fr Thanks for the plug. However, OCaml-Java is quite different and provides two tools: - an equivalent of ocamlrun written in Java (meaning you can interpret OCaml bytecode inside a JVM); - an equivalent of ocamlc/ocamlopt for Java (meaning you can compile OCaml sources to Java jar files to be executed by a JVM). Kind regards, Xavier Clerc ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] A js_of_ocaml equivalent for the JVM? 2012-03-09 18:05 ` forum @ 2012-03-12 16:05 ` Philippe Veber 2012-03-13 16:55 ` Richard W.M. Jones 1 sibling, 0 replies; 5+ messages in thread From: Philippe Veber @ 2012-03-12 16:05 UTC (permalink / raw) To: forum; +Cc: caml users [-- Attachment #1: Type: text/plain, Size: 3700 bytes --] Thank you Xavier and Johan for the replies. 2012/3/9 forum@x9c.fr <forum@x9c.fr> > > Le 9 mars 2012 à 18:45, Johan Grande a écrit : > > > Le 09/03/2012 18:12, Philippe Veber a écrit : > >> Dear camlers, > >> I used js_of_ocaml several times and was really stunned of how clever > >> (notably because writing interfaces boils down to writing types) and > >> efficient this approach is. Would a similar thing work for the JVM, that > >> is a compiler from ocaml bytecode to java bytecode? > > It is not easy to envision such a tool on the JVM, because of the current > restrictions imposed on Java bytecode. As an example, the size of a method > is currently limited to 64Ko, which is clearly way too small for non > trivial > programs. I see the point. It sure is a problem to reuse the same compilation scheme than in js_of_ocaml. > > > >> I guess it wouldn't > >> provide a full interoperability with java, in the sense that creating or > >> extending classes may not be possible (well, why not after all?). > >> However, being able to run an ocaml program on the JVM reusing existing > >> java libraries would be so useful already! > > I am currently working on this for OCaml-Java (see below). > I must admit one of the most exciting feature of js_of_ocaml (beside efficiency) is the way ocaml interfaces with javascript. I remember the procedure was much heavier with nickel. In another thread ( http://www.mail-archive.com/caml-list@inria.fr/msg02094.html) you said that this has changed in the version you're currently developing. I look forward to see how it works (I'm in if you need alpha testers). > > > >> Are there known obstacles to this? Has anyone tried something in this > >> direction? > > Well, no real obstacle as OCaml-Java showed. > However, OCaml-Java 1.x is still a bare proof of concept due to both > poor design choices and JVM limitations. But then came Java 1.7 and > some limitations were removed (e. g. a garbage collector better suited > to functional languages, and an implementation of method handles). > OCaml-Java has been largely rewritten and now exhibit acceptable > performances. > This is really great. > > > >> Would there be a chance to support multicore programming that > >> way? > > Yes, it is actually working. But not released yet. > Starting from vanilla OCaml, you "only" need two things: > 1/ have a reentrant runtime; > 2/ have a parallel garbage collector. > OCaml-Java implements the former, while all modern JVMs provide the latter. > So, basically, it just works. itou > The great difficulty is then to provide the good > abstractions to make the life of the programmer as easy as possible. > I mean: who would like to program with locks? > Well I'm not much into multicore programming myself, but at least for advertisement purposes, it cannot hurt ;o). > > > >> I hope these are not silly questions (sorry if they are!) > > > > http://ocamljava.x9c.fr > > Thanks for the plug. However, OCaml-Java is quite different and provides > two tools: > - an equivalent of ocamlrun written in Java (meaning you can interpret > OCaml bytecode inside a JVM); > - an equivalent of ocamlc/ocamlopt for Java (meaning you can compile > OCaml sources to Java jar files to be executed by a JVM). > Thanks for the news and clarifications! > > > Kind regards, > > Xavier Clerc > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > [-- Attachment #2: Type: text/html, Size: 5635 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Caml-list] A js_of_ocaml equivalent for the JVM? 2012-03-09 18:05 ` forum 2012-03-12 16:05 ` Philippe Veber @ 2012-03-13 16:55 ` Richard W.M. Jones 1 sibling, 0 replies; 5+ messages in thread From: Richard W.M. Jones @ 2012-03-13 16:55 UTC (permalink / raw) To: forum; +Cc: caml users On Fri, Mar 09, 2012 at 07:05:25PM +0100, forum@x9c.fr wrote: > Well, no real obstacle as OCaml-Java showed. > However, OCaml-Java 1.x is still a bare proof of concept due to both > poor design choices and JVM limitations. But then came Java 1.7 and > some limitations were removed (e. g. a garbage collector better suited > to functional languages, and an implementation of method handles). > OCaml-Java has been largely rewritten and now exhibit acceptable > performances. I tried out ocamljava (1.x) and really liked it. One thing that stopped me from using it was the fact that it 'emulates' a 32 bit OCaml environment, so we get all sorts of limits on strings and arrays. Will the new version 'emulate' 64 bit instead? Rich. -- Richard Jones Red Hat ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-13 16:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-03-09 17:12 [Caml-list] A js_of_ocaml equivalent for the JVM? Philippe Veber 2012-03-09 17:45 ` Johan Grande 2012-03-09 18:05 ` forum 2012-03-12 16:05 ` Philippe Veber 2012-03-13 16:55 ` Richard W.M. Jones
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox