7

Many modern programming languages (Scala, Erlang, Clojure, etc.) are targeting the JVM. What are the main reasons behind that decision?

  • JVM's maturity?
  • Portability?
  • Because JVM simply exists, and the language designers were not willing to write a new VM/interpreter?
sakisk
  • 3,397

5 Answers5

9

I'd say it's 10% option (a), 70% option (b) and 20% option (c).

Writing a reliable virtual machine is hard. It's a big part of why Perl6 was 10 years late - it runs on a register-based VM unlike the common ones and had to be written essentially from scratch). Also, you can leverage not just the VM but also the standard libraries, which are huge in Java.

But the major factor is probably that it is already on every conceivable platform - the direct competitor .NET is, in practice, Windows-only. And when you have already decided not to do your own VM, reusing the one that is most available is a no-brainer.

Kilian Foth
  • 110,899
9

Erlang is a standalone language but there is work being done on Erjang which is targeting the JVM. You're right that Scala and Clojure are targeting the JVM, and there are versions of Ruby and Python targeting the JVM as well (JRuby, Jython).

Yes, the JVM is a very mature platform and modern JVMs are able to optimize code and compile it on-demand to the host's native code for increased performance.

Yes, portability. Compiled Scala, Clojure, etc can be packaged using standard tools and distributed to any system that has a JVM (of a suitable version level).

Yes, the JVM means new languages "only" have to write a compiler to bytecode (and any supporting libraries they want to provide). They don't have to write a new runtime (which is what Erlang, Ruby, Python, JavaScript etc have all done in the past).

But I think you've missed one of the biggest benefits of the JVM: the huge ecosystem of libraries - both the Java standard library and the vast array of third party libraries are accessible to any language that targets the JVM.

2

An interesting historical footnote is that Martin Odersky, the creator of Scala was also the creator of a short-lived language called Pizza that was one of the first non-Java languages to target the JVM. It's implementation of generics was eventually incorporated in Java 5. You can read his interview on the origins of scala to get some insight into why he likes targeting the JVM.

jiggy
  • 1,590
0

You forget to add another reason:

  • It's what language designers know.

Significant bits of education (and, as a result, early work experience) for potential language designers are now being done in Java. See, for example, Wikipedia's history for Scala. As more and more developers are moving to using Javascript and its VM, you'll see newer languages running on that VM instead.

0

My estimation's:

  • 20% JVM's maturity
  • 50% Portability, especially of all the Java-libraries already available for the JVM
  • 30% Because JVM simply exists, and the language designers were not willing didn't have the time to write a new VM/interpreter.
DaveFar
  • 1,456