Creative Reality Pty Ltd

Creating a new reality

  • Increase font size
  • Default font size
  • Decrease font size

Why Scala

E-mail Print PDF
Article Index
Why Scala
Do More, Write Less
All Pages

I thought it might be useful to list a number of reasons for choosing to move to the Scala programming language as my primary language. Others may find these considerations useful when trying to decide whether is is worthwhile to learn some other language.

Speed

Scala is about as fast as Java, sometimes faster; and Java already has a reputation for being fast. This is an important feature for me as some algorithms I'm working on at the moment need pure speed. Groovy is a nice language, but lacks the raw speed of Java. While Groovy was good for general programming, fast stuff really needed to be written in Java. Now with Scala, there isn't any particular feature of Groovy I need that isn't provided by Scala.

Hybrid Object Oriented and Functional

Scala is a more object oriented language than Java. Everything is an object, there is no concept of primitive type.

Scala is a functional language. A number of functional features are very handy to have, like closures. When they are part of the language, you have a lot less typing to do and more chance that these features are implemented correctly.

Being a hybrid language, you can choose how functional you want to program. This is a significant advantage to people who only know OO programming. They can keep programming OO when they start using it and slowly become more functional over time. So there is no significant productivity loss when moving to Scala. This was one of the things I saw when moving from C to C++ in the early 90's. You could still program mostly like C but you could also do as much C++ style programming as you felt comfortable with as you continued to advance with the language.

Being a hybrid language, you are adding to what you can do and not trading off any nice features.

Runs on JVM

Scala interoperates with Java libraries. In fact, you can have a project that consists of Scala and Java source files.

Since I already know the libraries on the JVM, I can call them from Scala. No real learning there. Then I can learn more Scala specific libraries over time, while still being productive with the current Java libraries.

The JVM is a stable platform, the garbage collection and optimizations work reliably. The only real way that Scala can go wrong on this platform is by generating incorrect bytecode (or correct bytecode that does the wrong stuff) or holding on to references and causing memory leaks.

This leads to a very important risk-management advantage. If there are any issues with some Scala constructs not working or being inefficient, that functionality can be written in Java and called from Scala.



Last Updated on Tuesday, 18 May 2010 16:14