Published: July 2017
Explore functional programming and discover new ways of thinking about code. You know you need to master functional programming, but learning one functional language is only the start. In this book, through articles drawn from PragPub magazine and articles written specifically for this book, you’ll explore functional thinking and functional style and idioms across languages. Led by expert guides, you’ll discover the distinct strengths and approaches of Clojure, Elixir, Haskell, Scala, and Swift and learn which best suits your needs.
Functional programming is on the rise because it lets you write simpler, cleaner code, and its emphasis on immutability makes it ideal for maximizing the benefits of multiple cores and distributed solutions. So far nobody’s invented the perfect functional language—each has its unique strengths. In Functional Programming: A PragPub Anthology, you’ll investigate the philosophies, tools, and idioms of five different functional programming languages.
See how Swift, the development language for iOS, encourages you to build highly scalable apps using functional techniques like map and reduce. Discover how Scala allows you to transition gently but deeply into functional programming without losing the benefits of the JVM, while with Lisp-based Clojure, you can plunge fully into the functional style. Learn about advanced functional concepts in Haskell, a pure functional language making powerful use of the type system with type inference and type classes. And see how functional programming is becoming more elegant and friendly with Elixir, a new functional language built on the powerful Erlang base.
The industry has been embracing functional programming more and more, driven by the need for concurrency and parallelism. This collection of articles will lead you to mastering the functional approach to problem solving. So put on your explorer’s hat and prepare to be surprised. The goal of exploration is always discovery.
Five Questions for the Editor of Functional Programming: A PragPub Anthology
Q: This book is titled “Functional Programming: A PragPub Anthology.” First question: What’s a PragPub?
A: PragPub is a monthly magazine by and for software developers that I created in 2009 for the Pragmatic Programmers. It began as a showcase for the authors of their books, and has evolved into an independent publication. But we still have a close relationship with the Pragmatic Programmers, and we still feature many of their authors. This book, for example, includes chapters by Stuart Halloway, Venkat Subramaniam, and Dave Thomas, all of whom have written well-received books on the subjects they write about in this book.
Q: OK, how about the Anthology part? This is a collection of articles from the magazine?
A: It’s that, but I tried to put together a book that makes sense on its own. The chapters here are based on a selection from over a thousand articles we’ve published in the course of the past eight years. The idea was to look at one topic from a variety of perspectives, and with each perspective to have some introductory chapters and some more advanced chapters. Once I settled on a topic, I had a lot of articles on this topic to choose from, and I left out some really good ones because they didn’t fit the purpose of this particular book. Maybe they’ll be in the next one.
Q: And that one topic is functional programming?
A: Yes, and the different perspectives on it are its implementation five different languages: Clojure, Elixir, Haskell, Scala, and Swift. Each language embraces functional programming differently, implements functional capabilities in its own way, and encourages different styles of functional programming. It’s a matter of emphasis. I thought it would be useful to see these different perspectives on functional programming side by side.
Q: So readers can see which approach they prefer?
A: That, and because there’s virtue in seeing the same idea from different perspectives. You get a more rounded mental model of the concept. Take the avoidance of mutable state. That’s considered a defining feature of functional programming, but you see it differently if you think of it as a useful technique to use in certain circumstances as opposed to the default way to write functions. Seeing it from both those perspectives, I’m convinced, leads to a richer understanding.
Q: You mentioned the next book. Will there be more PragPub Anthologies?
A: The market willing. I have two more in the planning stages. Functional programming was a pretty obvious place to start. It’s a hot topic for programming books right now and it’s a particular interest of mine. We’ll probably return to it with a different approach, because there’s definitely a good solid book’s worth of functional programming material in the magazine. But the next one will probably be something quite different. And of course we keep publishing the magazine. The key article that the whole book coalesces around may be one we publish next month, or the next.
Published: July 2017