Jump to ratings and reviews
Rate this book

Functional Programming Patterns in Scala and Clojure: Write Lean Programs for the JVM

Rate this book
Functional languages have their own patterns that enable you to solve problems with less code than object-oriented programming alone. This book introduces you, the experienced Java programmer, to Scala and Clojure: practical, production-quality languages that run on the JVM and interoperate with existing Java. By using both the statically typed, type-inferred Scala and the dynamically typed, modern Lisp Clojure, you’ll gain a broad understanding of functional programming.

For each pattern, you’ll first see the traditional object-oriented solution, and then dig into the functional replacements in both Scala and Clojure. These patterns are common in the functional world and deserve to become part of your problem-solving toolkit. On the object-oriented side, you’ll see many common patterns, such as Command, Strategy, and Null Object. On the functional side, you’ll learn core functional patterns such as Memoization, Lazy Sequence, and Tail Recursion.

Each pattern helps you solve a common programming problem. Working through them gives you a set of patterns you can use to solve problems you come across while writing programs. Finally, you’ll learn how to work your existing Java code into new Scala or Clojure projects. You can start off small, adding functional code little by little, so you can complement your existing knowledge with Scala and Clojure as these languages gain popularity on the JVM.

250 pages, Paperback

First published October 15, 2013

19 people are currently reading
208 people want to read

About the author

Michael Bevilacqua-Linn

5 books6 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
9 (8%)
4 stars
31 (28%)
3 stars
40 (37%)
2 stars
22 (20%)
1 star
5 (4%)
Displaying 1 - 16 of 16 reviews
Profile Image for Sebastian Gebski.
1,211 reviews1,393 followers
April 15, 2014
No, just no.

Too simple, too crude & filled with uninspired examples - not enough even for a beginner. "Red book" (Functional Programming in Scala) is lightyears better (but also much harder to digest - be warned). I was also wondering what's the point in writing a book that covers FP for both Scala and Clojure - these 2 differ a lot and I don't think there are many people truly capable in both.

I feel disappointed. PragProg usually promises and delivers, but this time it just didn't work.
Profile Image for Rod Hilton.
152 reviews3,116 followers
November 15, 2013
Full Disclosure: I was a technical reviewer for this book. And the author was my roommate in college.

One of the things I always lament about "newer" programming languages is that, when I start using them, I often worry that I'm learning the language "wrong". In other words, I'm developing my own patterns and practices while working with the language, and I worry that they might be "worst practices" without my awareness. When faced with a new language or new paradigm, after learning the syntax and getting basic programs working, I immediately want to know how to write idiomatic code in the language. What are the best practices for working with the language, what are the standard patterns I'm not aware of?

I used Java for a long, long time but I never felt truly comfortable with it until I read Effective Java. I spent a few years writing Ruby full time but never felt confident until I read The Ruby Way. Knowing the idioms gives me a sense of confidence that I've now come to expect while working, so working without that confidence is jarring, and it makes it difficult to adopt and use new languages.

I'm not sure I'd say that this book is really the "Effective Scala" that I've been waiting for since adopting Scala at work a few years ago, but it's certainly a piece of the puzzle, and in that sense a very welcome addition to my library.

Less a book about Scala specifically, and more a book about functional programming in general, Functional Programming Patterns in Scala and Clojure provides a transition path away from the Object-Oriented paradigm that has been so popular and towards Functional Programming. The way of providing this path is two-fold: one, take the common patterns that OOP programmers feel comfortable with, and show how they apply (or don't) in a FP world and two, show them new patterns that have emerged out of FP. These tactics ease transition for folks like me, whose adoption of new languages means giving away the comfort of their language's syntax as well as the comfort that comes from confidence in idiomatic programming.

Rather than limit itself to a specific technology, the book shows how these patterns apply in both Scala and Clojure, so if you're looking at shifting toward either language, you can just focus on those examples. However, I recommend reading both anyway, as the book's approach provides a (perhaps unintentional) side-benefit. As a Scala programmer, I found myself obviously gravitating toward the Scala code in the book, but then when I'd read the Clojure section, it provided good 1-to-1 mappings from code I understood to code I did not, and it wound up helping me learn Clojure as well.

The book is largely introductory material, it doesn't go in depth in many areas, particularly with regard to the Functional Patterns. As an example, there's no chapter on Monads, which one might expect in a section on FP Patterns. I believe this is to keep the material accessible to every-day software developers, a lot of the more academic material usually associated with Functional Programming is left out. While I think this is the right choice for the book, I do believe that experienced FP programmers or those already very comfortable with Scala or Clojure may find the material too basic.

Functional Programming Patterns in Scala and Clojure is recommended to experienced OO developers who are dabbling with Functional Programming, but find that a discomfort with the topic pushes them away. This book will help them see how the knowledge they already have can transition along with them, rather than dumping them in the deep end and wishing them the best.

I'd give the book 5 stars but I don't want to look like some kind of shill, so I'm taking one star off because one, I'd have liked to see an Advanced Patterns section dealing with the more academic aspects of Functional Programming Patterns and two, I've seen the author in his underwear.
Profile Image for Zach Klippenstein.
14 reviews2 followers
May 30, 2014
Can't believe I paid almost $20 for this. The explanations are repetitive and written in a very boring prose. The code examples are hugely oversimplified, and are neither practical nor interesting. Anyone with a half-decent understanding of these patterns could have thought them up, and most could probably do better. The Scala code is often not idiomatic (e.g. using Vectors instead of lists, constructed without the :: constructor). I can't speak for the Clojure, I'm not as familiar with the language.

For one of the more interesting patterns, Memoization, after showing a completely naïve Scala implementation that ignores generics doesn't even try to demonstrate how to correctly use the type system, and instead just hard-codes the specific types being used in the example, I was really curious about what the Clojure code would look like. Instead, he just says there's a standard function to do it. I'm glad it was mentioned, but I would expect a $20 book would at least compare implementations.

I've read blogs that are more in-depth, better-written, and have more useful code examples than this drivel. Don't buy.
Profile Image for Leszek.
7 reviews
April 10, 2014
Most of the patterns in the book should be pretty obvious to somebody with any experience with functional languages. For me, the biggest gain was that I finally forced myself to touch Clojure...
Profile Image for Cuggiah.
278 reviews
October 6, 2023
buon libro per comprendere la programmazione funzionale
Profile Image for Vojtech.
378 reviews14 followers
December 25, 2013
You will probably benefit from this book the most if you are a seasoned Java developer and don't know much about programming in language with functional features. Only, you will have problems following the examples, because this is not a text book for Clojure or Scala. On the other hand if you know one of these languages, the patterns will probably be pretty obvious to you. So I'm not too sure what's the actual audience for this book.
2 reviews
June 18, 2014
It is easy to read but the examples are too simple and uninspiring.
PragProg is for me a reference but I won't finish this book.

If you know Java, Scala and Clojure then there are far better books to read because you already know what is inside.
If you don't know either Java, Scala or Clojure, you should get a book specifically about the language you want to know more about.
48 reviews2 followers
July 13, 2014
Most of the patterns described in the book are know if one knows how to program functionally. For me seeing how the patterns are implemented in Scala, convinced me not to invest too much learning Scala. The simplicity of Clojure is on the other hand very appealing.
Profile Image for Brian Cajes.
76 reviews1 follower
September 16, 2014
Great intro to functional programming. I liked the approach of starting with a common programming problem, reviewing the traditional patterns used to solve it, then walking through a functional way of solving it.
Profile Image for Sergey Shishkin.
162 reviews48 followers
July 21, 2014
It is amazing how a simple idea of first-class functions can render a whole palette of OO design patterns invisible... and a book about them unexciting.
Profile Image for Rocky Madden.
9 reviews17 followers
December 2, 2013
To the functional newbie, a solid introduction of moving from OO to FP concepts. To others, pass on this one.
Profile Image for Hussein.
13 reviews
November 27, 2013
Highly Important book for any "object oriented" programmer. If you already know functional programming, you aren't going to get any new info.
Profile Image for Luca Campobasso.
59 reviews2 followers
August 27, 2014
Amazing book! I know Scala and studying some Clojure, so this really suited me. It's a one-of-a-kind book and really well done! Hearthily suggested.
16 reviews
November 16, 2015
The code examples are rather bad style. Scala I don't know, but clojure ones are pretty non-idiomatic. Some examples are good but others are appalling.
Displaying 1 - 16 of 16 reviews

Can't find what you're looking for?

Get help and learn more about the design.