Should a new language compiler target the JVM?
- by Pindatjuh
I'm developing a new language. My initial target was to compile to native x86 for the Windows platform, but now I am in doubt.
I've seen some new languages target the JVM (most notable Scala and Clojure). Ofcourse it's not possible to port every language easily to the JVM; to do so, it may lead to small changes to the language and it's design. So that's the reason behind this doubt, and thus this question:
Is targetting the JVM a good idea, when creating a compiler for a new language?
Or should I stick with x86?
I have experience in generating JVM bytecode.
Are there any workarounds to JVM's GC? The language has deterministic implicit memory management.
How to produce JIT-compatible bytecode, such that it will get the highest speedup? Is it similar to compiling for IA-32, such as the 4-1-1 muops pattern on Pentium?
I can imagine some advantages (please correct me if I'm wrong):
JVM bytecode is easier than x86.
Like x86 communicates with Windows, JVM communicates with the Java Foundation Classes. To provide I/O, Threading, GUI, etc.
Implementing "lightweight"-threads.I've seen a very clever implementation of this at http://www.malhar.net/sriram/kilim/.
Most advantages of the Java Runtime (portability, etc.)
The disadvantages, as I imagined, are:
Less freedom? On x86 it'll be more easy to create low-level constructs, while JVM has a higher level (more abstract) processor.
Most disadvantages of the Java Runtime (no native dynamic typing, etc.)