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