What is the fastest language that runs on the JVM?
Scala? Groovy? JRuby?
What is the fastest language that runs on the JVM?
Scala? Groovy? JRuby?
Java.
Really, though, for the most part the speed difference will be negligible. Static languages will be faster than dynamic languages, but not by much.
Any language that compiles to bytecodes will run equally fast on a JVM with JIT.
As Anthony says, Java is the fastest language.
Languages with static typing (Java, Scala) are faster than dynamic ones (Groovy, JRuby).
See http://shootout.alioth.debian.org/. Java is very fast, Scala almost as fast. JRuby is 10-30 times slower. Groovy is slow too.
You have to be careful what you're comparing. As well as the "it depends what you're doing with it" that others have mentioned it also depends how you do it.
For example, a language like Scala can allow you to naturally express idioms and algorithms that you'd probably take a longer way around to do in Java. That's not to say that you couldn't match Scala's performance at doing the same thing - just that it may become an ugly workaround in one language to match the natural idioms in another (note I'm not saying I believe Scala is actually faster than Java at anything specifically - I have no data on that - other than that Scala is designed with scalability in mind - hence the name).
In other words, performance is usually about the algorithms and often the choice of algorithms are about ease of expression. So "use the right tools for the job" applies here - whether that tool happens to be Java, Scala, JRuby or whatever (although I doubt there are any situations where a dynamic language is faster than a static one without being pathological).
Of course we could also talk about profiling before optimising etc, but that doesn't directly address the question.
I think it would depend on what you mean by faster, and how well the language is written for performance.
For example, if you are doing something math intensive then Scala will be faster than Java.
But, if you avoid functions that are slow in java and use final in all places where it makes sense, you can get Java to run faster than Scala, from what I was told recently at an interview.
So, this is a hard question to answer in generalities, as people will show instances where Scala or Java will be faster.
But, I believe that Scala will generally be faster, if you are not using var
s, but val
instead.
See for yourself -
Current comparison - Java vs Scala vs JRuby
OUT OF DATE comparison - Java vs CAL vs Nice vs Scala vs JRuby vs Groovy