English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[ANN] OCaml-Java project: 1.1 release
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-11-11 (16:17)
From: forum@x9c.fr <forum@x...>
Subject: Re: [Caml-list] [ANN] OCaml-Java project: 1.1 release

Le 9 nov. 08 à 21:38, Warren Harris a écrit :

> Interesting project. Looks like you're mostly focused on getting  
> ocaml code to run in a jvm. Have you given any consideration to  
> making things work the other way around? I've found the ocaml  
> runtime to be far superior, and it would be nice to be able to  
> recompile a java library (source or class file) to run in an ocaml  
> program if need be. (For instance, I'd love to be able to recompile  
> Rhino into an ocaml module.)

The goal of the OCaml-Java project is clearly to be able
to run Objective Caml programs on a JVM. Additionally,
it is useful to access Java elements through automatic
binding generation.

Your (dual) suggestion of compilation of Java sources
into either OCaml sources of OCaml binaries for ocamlrun
(or even interpretation of Java bytecode) is interesting.
The Java language is clearly easy to parse, type, and
compile. However, the runtime support library would
be quite large (listing only the first items that come to
   - implementation of a 'native' method from the JDK;
   - explicit encoding of the algorithm for message dispatch;
   - explicit encoding of elements need by the reflection

These items are not intellectually challenging but you
would have to do a lot a work, especially for the coding
of all native methods (just consider the low-level GUI

You say that the ocaml runtime is "far superior".
I do agree but would like, as a concluding remark, to draw
your attention on the fact that the two runtimes are very
In OCaml, the compiler erases types, and all associated
safety is thus checked at compile-time. Then the produced
code (either bytecode or native) is supposed to be safe
and is run with no further consideration (hence its speed).

At the opposite, the Java compiler performs the bare minimum
checks. Then, at runtime the bytecode is verified before
execution. More, through the security manager some
checks are done at runtime to verify if the JVM is allowed
to access a file, open a network connection, etc.
All these runtime checks are obiously needed to grant the
user that some code will not harm its computer (e.g. inside