I am totally into Scala as a language ... and still I struggle with why any company should switch from Java to Scala. Is Scala just syntatic sugar on top of the JVM or are there fundamental improvements in Scala over Java that would improve real world applications?
|
Disclaimer: I'm not a Scala guru. Scala does two things extremely well which Java (currently) does not. Solve functional problems
But instead write something like:
Solve concurrency in a safer way
I can't honestly think of too much else that makes Scala stand head and shoulders above Java. Lots of small gains and improvements yes, but also far more rope to hang yourself with. YMMV HTH a little |
|||||||||
|
That depends on your definition of "just syntactic sugar". For instance, in what way is Java more than just syntactic sugar over machine code? Any language can do less than machine code, but no language can do more. What high level languages bring to the table is making code easier to read and understand, easier to compose, and catch more errors. And, in my opinion, it is the first of these that make most difference -- precisely "just syntactic sugar". But considering just the other two, there are still advantages of Scala over Java. Not to belabor the point, but having closures makes code way more composable than not having closures. And while Java 7 will add something called closures, they won't be that -- they'll just be anonymous functions. As for catching more errors, Scala's superior handling of variance is proof enough it does so. Furthermore, its emphasis on immutability also prevent all sorts of errors -- it is not that Java can't do immutable, but it just doesn't come with the library to do so. |
|||||||||||||||
|
On top of Martijn's answer I would like to add that Scala is more expressive than Java and the benefits are that (1) it makes you more productive (2) writing less code for solving the same problem means that you can reduce the bugs in your code (IMHO bug-free code is a myth). |
|||
|