In-Depth

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.

Are there any drawbacks to using Scala versus other programming languages?

One of the great aspects of Scala is that it carries along all of the advantages of the Java language itself while practically blending in important concepts from functional programming. Scala is typically used most often for application development (such as Web applications, business middleware, and mobile applications) and unlike Java itself, is also an excellent fit for lightweight scripting scenarios. Scala is not as good of a fit for systems-level programming, where C or contemporary systems languages such as Go might be more suitable.

What has led to the rise of high performance computing systems?

Traditional businesses are becoming ever more sophisticated in terms of the data they collect and the analysis they perform, while a new breed of Internet-scale applications such as LinkedIn and Twitter grew in popularity. At the same time, trends such as the arrival of massively multicore hardware and cloud computing put new resources at the disposal of technologists. Increasingly, every IT organization and startup faces challenges of the scale that previously would have been considered high-performance or scientific computing.

What kinds of industries would benefit from using Scala for their high-performing computing systems?

We see strong commercial demand and adoption in a few sectors. First, global financial services firms are rapidly adopting Scala and complementary frameworks such as Akka event-driven middleware to build the next generation of technology solutions that can keep up with today's massive scale markets in real time. Separately, we see strong demand from consumer-facing Internet firms that need to design their systems to scale rapidly as they grow -- whether they are new applications such as Twitter or traditional businesses gone online such as the Guardian UK.

What's the best way to train a programmer in Scala? Are there prerequisites -- such as a knowledge of Java -- that would help reduce the amount of training needed?

Our company, Typesafe, has created a standard hands-on training curriculum that gets developers up and running quickly with Scala and Akka. We are working with a growing number of partners to deliver these courses in cities around the world, and increasingly through on-site training at customer's facilities. At the same time, there are a growing number of books (http://typesafe.com/resources/books) about Scala (including my own!) and self-service resources such as Twitter's Scala School (http://twitter.github.com/scala_school/).

While many programmers come to Scala with a Java background, we also see many who have been programming with C#, Ruby, Python, or other functionally inspired languages.

What does Typesafe do?

Jonas Bonér, creator of Akka middleware, and I launched Typesafe in May 2011 to create a modern software platform for the era of multicore hardware and cloud-computing workloads. Typesafe provides an easy-to-use packaging of Scala, Akka, and developer tools via the open source Typesafe Stack, as well as commercial support and maintenance via the Typesafe Subscription. Typesafe also provides training and consulting services to accelerate the commercial adoption of Scala and Akka.

Must Read Articles