Hacker News new | ask | show | jobs
by fhars 5554 days ago
The JVM is quite a bad choice for languages like ocaml as it doesn't support full tail call elimination, which is a fundamental aspect for the predominant style of writing ocaml. So you would either have to simulate the ocaml stack on the java heap (slow and will probably make ocaml/java interop ugly, defeating the whole purpose of porting to the JVVM) or rewrite most of the existing ocaml code in a ocaml-for-the-jvm style that is quite different from normal ocaml style, taking into account which tail calls can be optimized and which cannot. And if you decide to go down that road, you will not gain much you cannot get by using scala right now, the only missing thing is camlp4.
1 comments

JVM tail recursion is done. It's available now and officially ships July 28th.
IIRC, the next JVM will indeed offer a new operation that allows tail calls (not exactly tailrec). However, this operation is incompatible with the Java security model (what you're allowed to do depends on what's above you in the stack -- this is used in many places in Java, in particular for anything related to accessing the screen or the file system, or more generally anything involving JNI) and with the Java exception model (exceptions contain the whole stack). Therefore, the operation will not be used by Java itself, and there are chances that using this operation in JVM languages without breaking compatibility with the Java stdlib will take some work, at least for the features that relate to security.
can you cite a source for this please