Q&A: An Introduction to the Scala Programming Language

We explore what the Scala programming language can do for your organization with the language’s inventor.

What is the Scala programming language, how does it work with Java, and what is its role in high-performance computing? We learn from the language’s inventor, Martin Odersky, who is also the chairman and chief architect of Typesafe, which packages Scala, Akka middleware, and developer tools into an open source stack.

Enterprise Strategies: What is Scala?

Martin Odersky: I created Scala as a statically typed programming language to run atop the Java Virtual Machine; Scala smoothly integrates features of object-oriented and functional languages, enabling Java and other programmers to be more productive. Scala is designed to express common programming patterns in a concise, elegant, and type-safe way.

How is Scala different than Java?

Scala is interoperable with Java and runs atop the Java VM, so existing Java code and programmer skills are fully re-usable. However, there are important differences between the two languages: fewer keystrokes to make, type inferencing, function passing, and many other features differentiate Scala from Java.

Scala is statically typed, meaning type checking is performed during compile time as opposed to run time, like Java but with Type Inferencing support. This means that the code is deeply analyzed by the Scala compiler to assess what type a particular value is. In Scala there’s no use of static all together. This is replaced by use of singleton objects. Singleton objects are declared by using the keyword “object” and not “class.

Also, when writing Scala code, the syntax for method declaration is different. Scala uses “=” before the method body, proceeded by the identifier of the method along with the parameter list and return type. Functions are treated like variables and constants.

Another important difference is that Scala supports the use of closures (anonymous functions) which makes longer code simpler and shorter, so many programmers often find writing Scala code easier and more efficient.

How does it help programmers of high-performance computing systems?

Scala is ideal for programmers of high-performance systems because it offers useful solutions for two important challenges -- concurrency and parallelism. For example, because Scala encourages developers to avoid shared mutable state, its much easier to build programs that are reliable while using available computing resources efficiently.