Book Review: Programming in Scala (atrtima)

Written by Martin Odersky, the creator of the language, Programming in Scala, 2nd Edition is a comprehensive guide to the language. It is a must read for every Scala programmer, because it goes beyond the technicalities of the language, and goes into the design philosophy and heart of the language. One of the big themes throughout the book is that functional programming and object oriented programming are not opposites of each other. In fact, both concepts can live in tandem to create a truly scalable language, which is where the name Scala comes from.

Scala can be written like Java because it runs on the JVM and can do all the things that Java can do. The authors of the book do a good job at convincing the reader to write Scala like Scala, and adopt a functional style of structuring algorithms. For example, a simple program to print arguments to stdout in imperative style would be:

var i = 0
while (i < args.length) {
    println(args(i))
    i += 1
}

But in a more functional style, the code would be much more concise and readable:

args.foreach(arg => println(arg))

The example code in the book is well thought out, demonstrating the power of the language through utilizing Scala's features such as functional data structures, traits, pattern matching and case classes. The book applies these techniques to problem spaces like constructing a representation of rational numbers and the n-queens problem.

With more than 800 pages of content, the book is very detailed, covering a wide range of topics such as testing, annotations and concurrent programming using the Actor model.

The most recent edition is the 2nd edition published in 2011, updated for Scala 2.8, but the contents of this book are still very relevant and should be on the desk of every Scala developer.