This international bestseller has been revised with new exercises, annotations, and full coverage of Scala 3.
In Functional Programming in Scala, Second Edition you will learn how
Functional Programming in Scala has helped over 30,000 developers discover the power of functional programming. You’ll soon see why reviewers have called it “mindblowing”! The book smooths the complexity curve of functional programming, making it simple to understand the basics and intuitive to progress to more advanced topics. Concrete examples and exercises show you FP in the real world and reveal how it can improve your everyday coding practices. This second edition comes packed with the latest standards of FP, as well as full code updates to Scala 3, and its new language features.
Foreword by Daniel Spiewak.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the Technology
Functional code is easy to test, reuse, and parallelize, and it’s practically immune to whole categories of state-related bugs. With its strong functional features, familiar syntax, and seamless interoperability with Java, there’s no better place to start learning functional programming than the flexible Scala language.
About the Book
In Functional Programming with Scala, Second Edition you’ll learn functional programming from first principles. Hands-on exercises and examples make it easy to start thinking and coding functionally. This revised edition contains extensive exercise annotations to help you explore FP in depth, along with steps to build your own functional libraries in Scala. Once the functional lightbulb goes on, you’ll never look at coding the same way again.
What’s Inside
About the Reader
For Java or Scala programmers. No knowledge of functional programming required.
About the Author
Michael Pilquist is the lead maintainer of FS2, a functional streaming library, and contributes to the Typelevel ecosystem. Paul Chiusano and Rúnar Bjarnason are recognized experts in functional programming and authors of the first edition of Functional Programming with Scala.
Table of
PART 1 - INTRODUCTION TO FUNCTIONAL PROGRAMMING 1 What is functional programming? 2 Getting started with functional programming in Scala 3 Functional data structures 4 Handling errors without exceptions 5 Strictness and laziness 6 Purely functional state PART 2 - FUNCTIONAL DESIGN AND COMBINATOR LIBRARIES 7 Purely functional parallelism 8 Property-based testing 9 Parser combinators PART 3 - COMMON STRUCTURES IN FUNCTIONAL DESIGN 10 Monoids 11 Monads 12 Applicative and traversable functors PART 4 - EFFECTS AND I/O 13 External effects and I/O 14 Local effects and mutable state 15 Stream processing and incremental I/O
Note: I was an early reviewer of this edition of the book for Manning and this description comes from that review process.
The first edition of this book was one of the first books I ever read about Scala. I had found the early chapters very readable but had increasing difficulty in the later chapters.
This edition seems to have overcome many of the difficulties I had with that first edition. While the later chapters introduce many difficult concepts, I find the discussion much more approachable. Perhaps some of that is due to the changes in the language itself, but I also think the authors have enhanced their approach a bit (though I haven't done a chapter-by-chapter comparison).
Even though the initial section does a very good job of presenting language features, I'm not sure this book is ideal for an initial jump into the Scala language. However, it doesn't assume any previous knowledge of the language. I think the authors have 'threaded the needle' pretty well between lengthy discussions of tedious details that can be summarized in a few tables (or links to additional information) and a too-brief presentation of the corners of the language. In other words, this book provides a good foundation in the language (with pointers to more info) without pages of detail that make your eyes glaze over.
The later chapters do a credible job of motivating more complex applications of functional programming and functional data structures and algorithms and then making use of Scala features to implement those concepts. Some of these implementations can be complicated and I had to refer back to previous chapters to get a decent understanding of exactly what was going on at times, but the effort was worthwhile.
This is easy among the top three tech books I ever read. I read the first edition a couple years back and I was very happy to see the second edition with the code samples updated and revised to Scala 3. The content in the book is rather advanced, abstract and not easy to grasp, especially for people who (like me) come from a strong OOP background. The reason why the book does a great job at teaching functional programming is because it doesn't confront the reader with the abstract concepts, but instead shows a number of concrete examples first and then introduces the abstractions that allow modelling the aspects all the examples have in common. This, in combination with the exercises, provides an ideal learning ground. The exercises are well thought out and have answers with detailed explanations, so there's always a way out if one gets stuck.
Compared to the first edition, the last part is the one that changed the most. It basically describes the foundation of fs2, which is a well known, production ready library. It is a great way to end such a book, because it shows that FP is a complete paradigm and it's very well suited for complex problem domains.
I recommend this book to all developers with some experience in programming. Not everyone will become a functional programmer, but everyone will learn something and become a better programmer in general.