I’ve started looking at Scala recently because it seems exactly the kind of language I would like to use as a complement to Java on the JVM: it’s similar to Java, but is a “pure” object oriented language and supports a shorter syntax, annotations, generics, closures, a functional programming style and mix-ins. Oh, and it’s fast, or at least seems to be from the little information that is available.
The fact that it’s statically typed is a huge plus in my eyes — I spent two and a half years as a PHP programmer before moving to Java, but think that dynamically typed languages are not for every task. Maybe I’m overgeneralizing, maybe.
Since Scala is rather new and doesn’t have many libraries yet, I’m sure there are plenty of exciting things that can and will be done in it, but I think there are a few areas where Scala should be especially useful. I’m talking about DSLs! Especially DSLs interacting with Java code (and preferably one way).
Trying to implement embedded DSLs in Java just doesn’t work. They are ugly, and even the so-called fluent interfaces in Java are of a somewhat dubious nature. Whenever I look at another piece of code like this …
… I think, what the hell are these people doing? And this is one of the least ugly examples. What they could be doing instead: writing their libraries in Scala. Since Scala is one of those DSL friendly languages and interoperates with Java easily (at least when Scala code is calling Java code, frankly I’m not sure how well the opposite dependency direction works), it should be awesome to write test/mock/specification libraries in Scala, for testing existing Java code. I can imagine that using those libraries would be a joy.
Since tests are separated from the main code anyway, or should be if you follow good practices, why not write them in a language that makes the code shorter and more readable?