Home‎ > ‎

Quick Overview of Scala

Scala is a multi-paradigm language that was designed to be highly scalable so that a few key language features would allow great flexibility and the ability to effectively extend the language through libraries. Some feel for the language can be achieved just by looking at how different paradigms are included.

Object-Oriented - Scala is completely object-oriented. Every value in Scala is an object. This differs from Java where you have a distinction between primitives and object types. In Scala, you can work with the value 5 just like any other object. This helps to make the syntax far more regular. For performance reasons, the Scala compiler will use primitives whenever possible, but that is transparent to the programmer. In addition, operators are methods called on these objects.

Functional - Scala has significant support for the functional paradigm as well. Functions are objects. That makes them first-class values. There are also function literals (closures) built into the syntax. As a result, a lot of the libraries include higher-order methods. Scala also encourages a functional style. It is easy to make variables constant, and immutable values are included in the libraries and generally favoured as part of proper Scala-style. In addition, all language control constructs in Scala, with the exception of the while and do-while loops, are expression. They all give back values.

Imperative - While functional is emphasised and there are language features that make it easy, Scala has full support for imperative programming as well. You can write code in Scala that works just like you would in Java. You can use mutable values and while loops if you so choose. You will likely find though that after a while you won't choose to do it that way because other features are so much more expressive and powerful.