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
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
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
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
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
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
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
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
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
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
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 đ