From Java to Java.Next – Quick Review of Scala

To start this quick review about Scala as Java.Next, let us see an interesting perceptive observation from Martin Fowler about Java and its legacy as follows.

“The legacy of Java will be the platform, not the language”

This statement is interested since more than 200 languages run on Java Virtual Machine (JVM) nowadays [1]. This condition emerges since Oracle hosted the annual JVM Language Summit in 2008, which has given implementers of alternative languages on the JVM an opportunity to collaborate openly with Java platform engineers. For example, let us consider Clojure, Groovy, Scala, and the new one, Kotlin. Each language brings interesting new capabilities beyond of Java language itself. In general, two initial significant advantages that these languages tend to provide are reducing the amount of verbosity in code. Hence it allows us to focus on the essence of problem solving. The second advantage is enabling some degree of functional programming styles [2]. This short review will be limited to Scala as an alternative programming language of Java.

As introduced in their official website [3], Scala is an elegant and concise programming language that integrates both functional and object-oriented paradigms smoothly. This enabling programmers to be more productive while retaining full interoperability with Java and taking advantage of modern multicore hardware. It is statically typed and well found with an expressive type system, which supports: generic classes, variance annotations, upper and lower type bounds, inner classes and abstract types as object members, compound types, explicitly typed self references, views, and polymorphic methods.

Since Scala runs on JVM which maintains a large amount of interoperability with Java, it aims to make substantial improvements on Java. Mostly by reducing verbosity and introducing a variety of functional programming elements. In additions, Java developers do not have to give up their existing work if they want to start using Scala in projects. There are at least three major improvements that Michael Pigg from Charlot Solutions stated regarding Scala over Java. The first two are appropriate with two advantages we describe earlier. They are in increasing productivity due to reduced verbosity and developers can mix and match imperative and functional programming paradigm as needed. Whereas the last one is built in functionality for parallelism and concurrency [4].

As well as in Java, Scala has built-in support for classes parameterized with types. It is useful for the development of collection classes [5]. Unlike in Java that has use-site variance annotations, Scala has declaration-site variance [6]. It also has exceptions handling system like in many programming languages. However, Scala does not actually have checked exeptions like in Java. As in Java, Scala uses a try{ … } catch { … } block, except that the catch block uses matching to identify and handle the exceptions [7].

One example of huge project that implements this language is Twitter. Much of its infrastructure is written in Scala [8]. Why not Java? Alex Payne, one engineering who involved in this project answers this question [9]. First of all, they really took Scala’s advantage of better concurrency. Twitter wanted to do more with fewer machines. They wanted to be compiled so it is not burning CPU doing the wring stuff. Secondly, it is very idiomatic, functional, and fast. Its community is small but growing and accessible. They also like the grand unified theory of Scala, which is combines OOP and functional programming. Moreover, they use traits, pattern-matching, and mutability.

After seeing some advantages of Scala over Java, It is reasonable to consider Scala as first alternative programming language in learning programming. However, since Scala is running on JVM and maintaining interoperability with Java, we should also learn Java side-by-side as a review in learning Scala.

Finally, below is the simple example taken from [10] to illustrate the advantages of Scala over Java language.


class Person(val firstName: String, val lastName: String)


public class Person {
    private final String firstName;
    private final String lastName;

    public Person(String firstName, String lastName) {
        this.firstName = firstName;
        this.lastName = lastName;

    public String getFirstName() {
        return firstName;

    public String getLastName() {
        return lastName;


  1. accessed in 21/05/2013
  2. accessed in 21/05/2013
  10. 10.

2 Replies to “From Java to Java.Next – Quick Review of Scala”

  1. A good code example would have been nice. The example you provided is weak and doesn’t show much of anything. Ironically, the Java code you are comparing Scala to is auto-generated by IDEs these days.

Leave a Reply