It is hard enough to remember my opinions, without also remembering my reasons for them! 👻
~ Nietzsche, as quoted in Moore’s and Mertens’ The Nature of Computation (Oxford).
I have no doubt in my mind that Scala is extremely well-positioned to serve as a bridge between the object-orientation of Java and the functional programming languages. My journey began several years ago with a highly readable book called Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (O’Reilly) by Austin-based Bruce Tate. And in case anyone wondered where the name “Scala” came from: “Scala” is the Italian word for stairway 👞 👡 👣 👢
Casting a glance back at my (ongoing) journey, here are the books that have proved most helpful to me in grokking Scala—I’ll take an opinionated look at the following books, in turn
- Programming Scala: Scalability = Functional Programming + Objects (O’Reilly), by Dean Wampler and Alex Payne ⛳
- Scala in Action (Manning) by Nilanjan Raychaudhuri 🚁
- Scala Cookbook: Recipes for Object-Oriented and Functional Programming (O’Reilly) by Alvin Alexander 🍔
- Scala in Depth (Manning) by Joshua Suereth 🏊
- Functional Programming in Scala (Manning), by Paul Chiusano and Rúnar Bjarnason 📐
- Scala for the Impatient (Addison-Wesley), by Cay S. Horstmann ⏳
1. Programming Scala: Scalability = Functional Programming + Objects (O’Reilly), by Dean Wampler and Alex Payne ⛳
If you’re going to read only one book on Scala, make it this one: Programming Scala: Scalability = Functional Programming + Objects (O’Reilly), by Dean Wampler and Alex Payne. It has been said about Scala—and very correctly so—that it has a very large surface area. In their book The Well-Grounded Java Developer, Evans and Verburg define it like so:
The surface area of a language is the number of keywords and independent language constructs that the working developer must master to be productive in the language.
2. Scala in Action (Manning) by Nilanjan Raychaudhuri 🚁
The book Scala in Action (Manning) by Nilanjan Raychaudhuri is another excellent book which has aged nicely over the years that I’ve programmed in Scala, and as my experience with it has grown. It’s target audience is clearly the enterprise software developer who is typically working with a massive code-base. While this book isn’t nearly as comprehensive a guide to Scala the language, it definitely has its strong points. One thing I really appreciated was how the author introduces each chapter with an engaging prelude; with the captivating motivational material to grab you up-front, the ensuing narratives in the chapters each flow smoothly, and the chapter-to-chapter transition is pleasing and smooth as well.
Another quality of this book that I appreciated a lot are the copious footnotes, containing pointers to useful references for the reader to explore (The quality of these references is especially high, much more so than I typically find in other books—Kudos to the author for painstakingly researching and then culling the research to share only the very best references).
This book is particularly good for those transitioning from Java to Scala. James Gosling (the renowned designer of the Java programming language) has said
If I were to pick a language to use today other than Java, it would be Scala.
If that description fits you, then this Scala in Action the book for you. I found it especially strong in its coverage of the inevitable topic that’s highly relevant for seasoned Java programmers—interoperability between Scala and Java. I liked the author’s take on working with Java generics and collections, on solving integration challenges, plus a nice bonus on building web applications in Scala while using Java frameworks.
3. Scala Cookbook: Recipes for Object-Oriented and Functional Programming (O’Reilly) by Alvin Alexander 🍔
The programming cookbooks are perennial favorites with many of us software developers. This one, entitled Scala Cookbook: Recipes for Object-Oriented and Functional Programming (O’Reilly) by Alvin Alexander follows in the fine tradition of the legendary programming cookbooks published by O’Reilly. Probably the first thing you will note is this book’s size! Coming in at 722 pages, it’s quite the boat anchor, and not for the faint of heart 😉
Joking aside, I think highly of this book from a fellow Aggie. Think of this tome as high octane fuel to propel your programming adventures in Scala. It is replete with all things common sense and pragmatic about doing things the Scala way.
What I appreciate the most about this book is its relentless focus on serving the reader with recipe after recipe of high-quality code—undoubtedly coming straight from the trenches of software development in Scala—accompanied by insights into the why and wherefore of the rationale taken by any given recipe. If pragmatic, no-nonsense advice (on nuts-and-bolts Scala programming) is what you’re after, this is the book for you. My first taste for the pragmatism that the author brings to the pages of this book came with this delightful self-introduction. Thus, while introducing his circuitous route to software development (after getting a degree in Aerospace Engineering from Texas A& M University), the author says
…Once he became a practicing engineer, he realized he liked software and programming more than engineering. So in approximate order he taught himself Fortran, C, Unix and network administration, sed, awk, Perl, Java, Python, Ruby, JRuby, Groovy, PHP, and Scala. During this process he started a software consulting firm, grew it to fifteen people, sold it, and moved to Alaska for a few years…
In a nutshell—much as the author himself notes in the Preface—this book is
…a cookbook of problem-solving recipes about Scala, the most interesting programming language I’ve ever used. The book contains solutions to more than 250 common problems, shown with possibly more than 700 examples. (I haven’t counted, but I suspect that’s true.)
4. Scala in Depth (Manning) by Joshua Suereth 🏊
I’ve got a confession to make: This next book that I am about to recommend, I do so with a tad bit of trepidation, because it has challenged and stretched to its limits—and continues to do so—my conceptualization of the expansive solution space spanned by the true Scala way of doing things…
This book, Scala in Depth (Manning) by Joshua Suereth, is the work of a programming virtuoso! Having made the confession above, I’m glad to have doggedly stuck to grokking the sublimely intricate themes to be found in its pages. While this is definitely not your first, or even second, book on Scala, please don’t let that deter you. Repeatedly trekking over and dipping into its pages—that’s what I’ve been doing the past several years—will be time supremely well invested. Once you’ve read a couple of books on Scala, experimented at the REPL to your heart’s content, and are writing some significant Scala code, this book will be your guide to some amazing things that this amazing language equips you with.
To use the notion of SNR—Signal-to-Noise Ratio, of which all engineers get disabused at one time or another during their training—this masterpiece has practically zero fluff. In my mind, this book will easily still be around for another decade, serving as a rich source of insights into Scala, for developers like us to mine and benefit from. It’s rather difficult to convey the richness of topics covered quite thoroughly in this fantastic compendium of relatively advanced themes in the Scala solution space. What will help convey that richness as a prelude are these words of the stunningly brilliant and creative computer scientist, Martin Odersky—designer of the Scala language—which he offers in the book’s Preface:
Joshua Suereth is one of the most complete programmers I know. Familiar with a whole gamut of programming languages and techniques, he is an expert in high-performance systems, build tools, type theory, and many other areas. He is also a gifted teacher, and all that combined is what makes Scala in Depth special.
This book provides in-depth coverage of several of the more intricate areas of Scala, including advanced aspects of its type system, implicits, composition techniques with traits, collections, actors, functional categories. But this is not a dry recollection of language and library concepts. The book is full of practical advice on how to apply these lesser known parts of Scala in useful ways, and what the best practices are…
If what you’re looking for is expert guidance on how to write idiomatic Scala code and understand trade-offs when making use of advanced language features, you will like this book immensely. The type system in Scala is covered exceptionally well, as are patterns in functional programming (ala Scala), and you can’t help but appreciate the author’s unique take of promoting “…the blended style of Scala, where paradigms are mixed to achieve something greater”. As the author himself notes
Scala provides the tools needed to blend the object-oriented and functional programming worlds. Scala is at its best when these two evenly share a codebase. The biggest danger to misusing Scala is to ignore its object orientation or its functional programming. But combining the two is the sweet spot that the language was designed to fulfill.
5. Functional Programming in Scala (Manning), by Paul Chiusano and Rúnar Bjarnason 📐
I found a gem of a book in this next title: Functional Programming in Scala (Manning), by Paul Chiusano and Rúnar Bjarnason. This book provided the perfect answer to a vexing question that had been dogging me for a while—In the words of Scala’s creator, Martin Odersky, who has articulated that exact question so articulately as follows, in his Foreword to this book
So to properly learn functional programming in Scala, should one make a detour via a pure functional language such as Haskell?
So I got started a bit with Haskell—Got the GHC (Glasgow Haskell Compiler) and read parts of the book The Haskell Road to Logic, Maths and Programming (College Publications), by Kees Doets and Jan van Eijck. But I wasn’t sure—actually, still am not—whether I wanted to invest time in learning the rather alien-looking syntax of Haskell, let alone grok its idioms. Luckily for me, this book (Functional Programming in Scala) came along, and which I read via Manning’s MEAP (Manning Early Access Program). As Martin Odersky continues in his Preface, answering the vexing question that I alluded to earlier, he elaborates
Any argument in favor of this approach has been severely weakened by the appearance of Functional Programming in Scala… What Paul and Rúnar do, put simply, is treat Scala as a pure functional programming language. Mutable variables, exceptions, classical input/output, and all other traces of impurity are eliminated. If you wonder how one can write useful programs without any of these conveniences, you need to read the book. Building up from first principles and extending all the way to incremental input and output, they demonstrate that, indeed, one can express every concept using only pure functions. And they show that it is not only possible, but that it also leads to beautiful code and deep insights into the nature of computation.
Without a shadow of a doubt, this book is challenging—and I continue to work through it—but that challenge originates in the fundamentally different (functional) way in which it invites us to think about programming (i.e. contrasted with the pervasive object-oriented paradigm in which the vast majority of us swim nowadays). This is a book you likely won’t regret reading; to give you a sense of the topics covered, here is the Table of Contents:
1. Introduction to functional programmingChapter 1. What is functional programming? Chapter 2. Getting started with functional programming in Scala Chapter 3. Functional data structures Chapter 4. Handling errors without exceptions Chapter 5. Strictness and laziness Chapter 6. Purely functional state
2. Functional design and combinator libraries Chapter 7. Purely functional parallelism Chapter 8. Property-based testing Chapter 9. Parser combinators
3. Common structures in functional design Chapter 10. Monoids Chapter 11. Monads Chapter 12. Applicative and traversable functors
4. Effects and I/OChapter 13. External effects and I/O Chapter 14. Local effects and mutable state Chapter 15. Stream processing and incremental I/O
The bottom-line with this gem—Functional Programming in Scala—is that it will challenge you, and jolt you out of your comfort zone. But if you’re up to it, you’ll be richly rewarded.
6. Scala for the Impatient (Addison-Wesley), by Cay S. Horstmann ⏳
Although not in the same league as the preceding books, this book is especially good in covering the syntax of Scala both succinctly and comprehensively. I reckon the title says it all: Scala for the Impatient (Addison-Wesley), by Cay S. Horstmann. This book will be especially helpful for anyone coming brand new to Scala. When I read it, I was quite impressed by how the author had diligently crafted the material to help the reader—typically, someone coming from Java to Scala—bridge the chasm between the two languages.
It also contains lots of tips and tricks—common gotchas that trip up beginning Scala programmers. In fact, this quality, combined with its succinctness and comprehensiveness, makes it a good reference to have around. In the words of Martin Odersky
I am very happy that his book has finally arrived because it really delivers on what the title says. It gives an eminently practical introduction to Scala, explains what’s particular about it, how it differs from Java, how to overcome some common hurdles to learning it, and how to write good Scala code.
This books nicely addresses for beginners the essential challenge of Scala being a language with a very large surface area (and to which I had alluded earlier). In fact, much as the author himself notes in the book’s Preface
Scala is a big language, but you can use it effectively without knowing all of its details intimately.
With these caveats, Scala for the Impatient is definitely a book worth exploring.
In the end, and as I mentioned at the outset, I invite your comments—Having now read my brief take each on the books above…
- Do you find that your experience of reading any of these books was different?
- Perhaps some qualities that I did not cover are the ones that you found the most helpful as you learned Scala and its ecosystem.
- Did I leave out any of your favorite Scala book(s)?
- I’ve covered only a partial list of the Scala books that I’ve read, necessarily limited by the time available…
My hope is that these brief vignettes will help you in your journey to grokking Scala. Bon voyage, and I leave you with a photo of a pseudo-random section—which is clearly biased toward Scala material—of one of my bookshelves 😅