- Paperback: 250 pages
- Publisher: Pragmatic Bookshelf; 1 edition (November 2, 2013)
- Language: English
- ISBN-10: 1937785475
- ISBN-13: 978-1937785475
- Product Dimensions: 7.5 x 0.5 x 9.2 inches
- Shipping Weight: 1.1 pounds (View shipping rates and policies)
- Average Customer Review: 10 customer reviews
- Amazon Best Sellers Rank: #1,444,934 in Books (See Top 100 in Books)
Enter your mobile number or email address below and we'll send you a link to download the free Kindle App. Then you can start reading Kindle books on your smartphone, tablet, or computer - no Kindle device required.
To get the free app, enter your mobile phone number.
Functional Programming Patterns in Scala and Clojure: Write Lean Programs for the JVM 1st Edition
Use the Amazon App to scan ISBNs and compare prices.
All Books, All the Time
Read author interviews, book reviews, editors picks, and more at the Amazon Book Review. Read it now
Frequently bought together
Customers who bought this item also bought
Q&A with Michael Bevilacqua-Linn, author of "Functional Programming Patterns in Scala and Clojure"
Q. Why did you write "Functional Programming Patterns"?
A. Languages with a functional flavor are getting more and more mainstream, and I wanted to write something that would help folks with a lot of traditional OO pattern knowledge start to make the transition.
Q. I don't know Scala or Clojure. How hard would it be for me to understand the examples in the book?
A. This book is written for programmers who are new to Scala and Clojure, but who have significant experience with Java and object-oriented patterns. One of its goals is to help ease experienced object-oriented programmers into a more functional style.
Q. What can I do with functional patterns that I couldn't do before?
A. It's not so much what you can do, as what you can do better! Functional programming, and the patterns that go along with it, tends to be more declarative than imperative programming, so you can solve problems with code that's both more straightforward and shorter. The functional focus on immutable data reduces bugs in large programs, especially ones involving concurrency.
Q. Functional programming has no place in the object-oriented world, does it?
A. While object-oriented programming and functional programming are often seen as opposite paradigms, the truth is a bit more complex. Even Java is getting more of a functional style with Java 8's Lambdas. Scala explicitly blends object-oriented and functional styles. While Clojure is explicitly not object-oriented, it does borrow many good ideas from the object-oriented world, such as polymorphism and programming to interfaces.
Q. Which one should I use? Scala or Clojure? What are the differences and which would be easier to start with?
A. Scala tends to provide an easier on-ramp for object-oriented programmers, as they can start working with it in a mainly object-oriented style and transition to a more functional style as they gain more experience. Scala also has a sophisticated static type system, and blends object-oriented and functional programming together. Clojure, on the other hand, is a modern, practical Lisp and comes with the powerful macro system inherent to Lisps.
Both are excellent, general-purpose languages, but I have to confess that I prefer Clojure. I find that I can write clear, concise code it in much more easily than I can in any other language. However, knowing both will give you a very broad understanding of modern languages with a functional flavor.
5 Functional Programming Tips from Michael Bevilacqua-Linn, Author of “Functional Programming Patterns in Scala and Clojure”
- Look for opportunities to replace object-oriented patterns with simpler functional language features.
- Don't be afraid to create functions that return functions.
- Consider composing behaviors using higher order functions rather than building hierarchies.
- Reach for higher order functions over collections before recursion.
- You often don't need mutability, even when you think you do! Try to find a higher order function that helps you transform an immutable data structure into a new, immutable data structure rather than modifying it in place.
"This book is an absolute gem and should be required reading for anybody looking to transition from OO to FP. It is an extremely well-built safety rope for those crossing the bridge between two very different worlds. Consider this mandatory reading."
"This book sticks to the meat and potatoes of what functional programming can do for the object-oriented JVM programmer. The functional patterns are sectioned in the back of the book separate from the functional replacements of the object-oriented patterns, making the book handy reference material. As a Scala programmer, I even picked up some new tricks along the read."
"This book is good for those who have dabbled a bit in Clojure or Scala but are not really comfortable with it; the ideal audience is seasoned OO programmers looking to adopt a functional style, as it gives those programmers a guide for transitioning away from the patterns they are comfortable with."
Top customer reviews
I think it is very important to avoid leading readers using only examples which are easily handled with a functional approach. This book achieves this with challenging material. I was surprised that I could not simply read the book and gain a rapid understanding, but had to go and really do the exercises with the author. I am told by a number of experts that this is typical for imperative-minded programmers. But I really want to learn functional programming, so I'm glad I purchased this book!
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.
Functional patterns part is also great. It covers lazy evaluation, mutual recurcion and many others.
You will not find avdanced Scala techniques in this book, but again, very good read for somewhat familiar with Scala syntax and willing to learn how to actally apply functional style patterns in their everyday programming.
You won't regret it, it's worth much more than I payed for.
Helps people with an extensive OO background move into the functional realm, which I think is much more challenging that learning new language syntax.
Examples are well-chosen and highlight very useful language features, simultaneously helping one move from OO to functional.