Chaminda Amarasinghe wrote:
I have heard, I think for twitter CTO, Scala is faster than Java. My question is, if scala runs on JVM, why java cant achieve that fast, which is originally designed to run on JVM?
What I heard from twitter is Scala gives them higher productivity than Java
Marco Ehrentreich wrote:
Even if the language is more expressive or concise for lots of use cases it still compiles to bytecode which runs on the same VM...
I'm pretty sure that the things that make a language dynamic are the same things that make it slower to execute than straight Java. Any expert want to weigh in on this?
Marco Ehrentreich wrote:It's in that case where I don't think it makes much difference when both languages can be compiled to bytecode.
Compiling to bytecode isn't the key. Groovy compiles down to bytecode, but the metaprogramming features that do things like letting you add methods to final classes at runtime make Groovy slower than Java.
Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Code sizes are typically reduced by a factor of two to three when compared to an equivalent Java application
Carl Smotricz wrote:From what I've learned of Scala so far, there's no big technical advantage to running Scala vs. Java code. In fact, head to head on a single CPU, compiled Scala code often loses a cycle or two against Java, simply because the Scala compiler hasn't yet seen as many years of industrial-strength optimization.
Pat Farrell wrote:You still run on a single CPU?
Carl Smotricz wrote:As things stand, without having done any research, I'd wager that better than 90% of all Java code worldwide fits in this "single CPU" category. Multi-core systems are being used to run different applications side-by-side (so your virus scanner hurts less) or to run multiple copies of the same job (like ebay bids). Java applications where a single task is distributed to a number of threads/cores form a small minority.