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 may lead to small changes to the language and it’s design.
After posing this question, I even doubted more about this decision. I now know some “pro” JVM arguments. The original question was: is targetting the JVM a good idea, when creating a compiler for a new language?
Updated the question: What are the disadvantages of targeting the JVM instead of x86 on Windows?
Targeting the JVM is a pretty tried and tested approach. The fact that Clojure, Scala, JRuby and many other languages have done so successfully should give you some reassurance.
My view overall is that the JVM is probably the best target at the moment for new/experimental languages, particularly if you hope to achieve cross platform capability while taking advantage of a truly fantastic JIT compiler and a wealth of very powerful libraries.
Having said that, the main disadvantages you may encounter targeting the JVM are in my opinion as follows:
Lack of tail recursion support at the bytecode level. There are ways around this (e.g. see Clojure’s “recur” special form) but it is annoying for some language implementations, particularly functional languages. Will probably eventually be fixed in future versions of Java.
Slightly obvious, but you need a JVM installed on your client. Usually not a problem nowadays, but there are still cases where this can be tricky.
Primitives (int, long, float etc.) in Java behave differently from the rest of the object system. Again you can work around this but it is some extra hassle for language implementers.
Some potentially useful/interesting links:
ASM bytecode analysis and manipulation framework. This is a great tool,
I believe it is what what Clojure uses under the hood.
Clojure source code