Who This Book is For

“I never teach my pupils. I only attempt to provide the conditions in which they can learn.”

Albert Einstein

I kept several audiences in mind as I wrote this book:

  1. Developers who want a simple introduction to functional programming in Scala
  2. Developers who are interested in writing “better” code
  3. Parallel/concurrent application developers
  4. “Big data” application developers
  5. (Possibly) Upperclass college students

Here’s a quick look at why I say that I wrote this book for these people.

1) Developers who want a simple introduction to FP

First, because this book started as a series of small notes I made for myself as I learned about functional programming in Scala, it’s safe to say that I wrote it for someone like me who has worked with OOP in Java, but has only a limited FP background. Specifically, this is someone who became interested in Scala because of its clean, modern syntax, and now wants a “simple but thorough” introduction to functional programming in Scala.

Because I’ve also written programs in C, C++, Perl, Python, Ruby, and a few other programming languages, it’s safe to say that this book is written with these programmers in mind as well.

2) Those interested in writing “better” code

At specific points in this book — such as (a) when writing about pure functions, (b) using val and not var, and (c) avoiding the use of null values — I also wrote this book for any developer that wants to write better code, where I define “better” as safer, easier to test, and more error-free. Even if you decide not to write 100% pure FP code, many FP techniques in this book demonstrate how you can make your functions and methods safer from bugs.

As a personal note, an ongoing theme in my programming life is that I want to be able to write applications faster, without sacrifing quality and maintainability. A selling point of FP is that it enables you to write safe functions — pure functions that rely only on their inputs to produce their outputs — that you can then combine together to create applications.

3) Parallel/concurrent developers

In addition to writing safer code, the “killer app” for FP since about 2005 is that CPUs aren’t constantly doubling in speed any more. (See Herb Sutter’s 2005 article, The Free Lunch is Over.) Because of this, CPU designers are adding more cores to CPUs to get more overall CPU cycles/second. Therefore, if you want your apps to run as fast as possible, you need to use concurrent programming techniques to put all of those cores to use, and the best way we know how to do that today is to use FP.

Two of my favorite ways of writing parallel/concurrent applications involve using Scala futures and the Akka messaging/actors framework. Not surprisingly, FP works extremely well with both of these approaches.

4) “Big data” app developers

More recently, Dean Wampler gave a presentation titled, “Copious Data: The ‘Killer App’ for Functional Programming”. My experience with Big Data applications is limited to processing large Apache access log records with Spark, but I can confirm that the code I wrote was a lot like algebra, where I passed data into pure functions and then used only the results from those functions. My code had no dependence on “side effects,” such as using mutable variables or managing state.

5) Upperclass college students

As I wrote in the Scala Cookbook, because of its “power user” features, I don’t think Scala is a good first language for a programmer to learn, and as a result of that, a book about Scala/FP is also not a good first programming book to read.

That being said, I hope this will be a good first FP book to read after a college student has experience with languages like C, Java, and Scala. When I started writing this book, my nephew was a senior in college and had some experience with C and Java, and as I reviewed the chapters I’d ask myself, “Would Tyler be able to understand this?”

Caution: Not for FP experts

Finally, as a result of the people I have written this book for, it should come as no surprise that this book is not written for FP experts and theorists. I offer no new theory in this book; I just try to explain functional programming using the Scala programming language in the simplest way I can.

books i’ve written