As you can probably tell from my recent posts, I’ve been learning Scala. I recently dug into another Scala book, Beginning Scala by David Pollak.
Beginning Scala is a nice, gentle introduction to this language. It takes a gradual, example driven approach that emphasizes running code early. This makes it a good intro for people who want to use the language for applications first, then worry about creating frameworks later.
Don’t let that fool you, though. Pollak gets to the sophisticated parts soon enough. I particularly like a example of creating a new “control structure” to execute stuff in the context of a JDBC connection. This puts some meat on the argument that Scala is a “scalable language.” Where other languages either implement this as a keyword (as in Groovy’s “with”) or a framework (Spring’s “templates”), here it can be added with one page of example code.
Beginning Scala also has a very thorough discussion of actors. I appreciate this, because actors were my main motivation for learning Scala in the first place.
Pollak separates the act of consuming a library from that of creating a library. He advises us to worry most about types, traits, co- and contravariance, etc. mainly when we are creating libraries. True to this notion, chapter 7 is called “Traits and Types and Gnarly Stuff for Architects”. It doesn’t sound like much fun, but it is important material. I find that Scala makes me think more about the type system than other languages. It’s strongly, and statically, typed. (So much so, in fact, that it makes me realize just how loose Java’s own type system is.) As such, it pays to have a firm understanding of how code turns into types. Scala has a rich set of tools for building an expressive type system, but there is also complexity there. Checking in at 60 pages, this chapter covers Scala’s tools along with guidance on good styles and idioms.
Interestingly, although there is a Lift logo on the cover, there’s nothing about Lift in the book itself. Considering that Pollak is the creator of Lift, it’s curious that this book doesn’t deal with it. Perhaps that’s being left for another title.
Overall, I endorse Beginning Scala.