Click the table of contents to start reading.
Grokking Functional Programming is a practical book. Written especially for object-oriented programmers, it will help you map familiar ideas like objects and inheritance to FP concepts such as programming with immutable data, higher order functions, composing functions, concurrent programming and even the dreaded monad. And you'll be pleased to know that we skip the academic baggage of lambda calculus, category theory, and the mathematical foundations of FP in favor of applying functional programming to everyday programming tasks. At the end of the book, you'll be ready to pick a functional language and start writing useful software.
Part 1: The Functional Toolkit
1 Learning Functional Programming
Perhaps you picked up this book because…
What do you need to know before we start?
How do functions look like?
Meet the function
When the code lies…
Imperative vs declarative
Coffee Break: imperative vs declarative
Coffee Break Explained: imperative vs declarative
How useful is learning functional programming?
Leaping into Scala
Practicing functions in Scala
Getting our tools ready
Getting to know the Scala REPL
Writing your first functions!
How to use this book?
2 Pure Functions
Why do we need pure functions?
Breaking the code
Passing copies of the data
Breaking the code… again
Recalculating instead of storing
Focusing on logic by passing the state
Where did all the state go?
Difference between impure & pure functions
Coffee Break: refactoring to a pure function
Coffee Break Explained: refactoring to a pure function
In pure functions we trust
Pure functions in programming languages
Difficulty of staying pure…
Pure functions and clean code
Coffee Break: pure or impure?
Coffee Break Explained: pure or impure?
Using Scala to write pure functions
Practicing pure functions in Scala
Testing pure functions
Coffee Break: testing pure functions
Coffee Break Explained: testing pure functions
3 Immutable Values
4 Functions as Values
Part 2: The Functional Techniques
5 Pipelines & Comprehensions
6 Error Handling
7 Behaviors vs Data
8 Functions and Types
10 Data Streams
Part 3: Applied Functional Programming
13 Case Study #1
14 Case Study #2
15 Case Study #3
About the Technology
Functional programming is more than just writing the same old code in Scala, Clojure, or Haskell. To grok FP—to really get it—you need to rewire your brain to see the world differently. We're here to help you flip the switch. Grokking Functional Programming teaches you first to break down problems in a new way so you can approach them from a FP mindset. Following carefully-selected examples with thorough, carefully-paced explanations, you'll immerse yourself in FP concept by concept. Along the way, exercises, checks for understanding, and even the occasional puzzler give you opportunities to think and practice what you're learning.
- Designing with functions instead of objects
- Multiple learning approaches to help you grok each new concept
- A practical programming-first teaching style
- Programming with immutable collections
- Writing concurrent programs with a functional style
About the reader
Examples use Scala as the teaching language, but this is not a Scala book. No prior knowledge of Scala or FP is required.
About the author
Michał Płachta started using Scala commercially in 2014 and has been an active contributor to the Scala and JVM communities since. He regularly speaks at conferences, runs workshops, and organizes meetups to help others become better at functional programming. You can find his blog at michalplachta.com.
Aslam Khan is a software developer whose foray into functional programming was out of necessity, not curiosity. Aslam uses FP daily for production work.
placing your order...Don't refresh or navigate away from the page.