Java – scalablity of Scala over Java

concurrencyjavascalascalability

I read an article that says Scala handles concurrency better than Java.

http://www.theserverside.com/feature/Solving-the-Scalability-Paradox-with-Scala-Clojure-and-Groovy

…the scalability limitation is confined specifically to the Java programming language itself, but it is not a limitation of the Java platform as a whole…

The scalability issues with Java aren't a new revelation. In fact, plenty of work has been done to address these very issues, with two of the most successful projects being the programming languages named Scala and Clojure…

…Scala is finding ways around the problematic thread and locking paradigm of the Java language…

How is this possible? Doesn't Scala use Java's core libraries which brings all the threading and locking issues from Java to Scala?

Best Answer

Well, of course it does. And Java reuses all the infrastructure provided by the JVM, which was written in C, and it ultimately runs in machine code!

The point of enabling developers to let their applications scale is not to provide more raw power. Assembler already has all the power that your hardware allows, and no language can provide more. In fact, the entire point of higher-order languages is to restrict what programmers can do in them them. That sounds horrible, but the bottleneck in writing great, correct, efficient code is not the computation model. It is the brains of the people who have to understand the programs written for the machine. Experience has shown that we are not smart enough to understand the theoretically optimal solution of a complex computation problem; we would probably not even recognize it if we saw it.

In the concrete example, the article presumably means that Scala provides higher-level libraries and concepts that make it easier for developers to understand their problems from the perspective of concurrency, and so the end result is better and more scalable than coding directly in Java (or C, or Assembler) would have been. That doesn't contradict the fact that Scala runs entirely on top of a Java virtual machine. The JVM is a beautiful invention that allows all kinds of neat stuff to be written more easily than would be possible without it - including frameworks and libraries that make even more complex things easy. Amazing, isn't it?

Related Topic