I will just write a short review. There’s only one available at the time by Stefan Kanev on Goodreads. Here’s the complete review. I reference his review a few times. So if you want the complete picture read both. Or just skip to the bottom to the TL;DR.
The book currently costs $12 for digital version and $19 for digital + print. It’s officially 112 pages long. I’ll start with the stuff I liked. The illustrations were nice. The author didn’t write too fluffy. And it was a quick read (took me around 45 minutes).
Who’s the audience?
However, there are a lot of problems. I start with the first one: Who’s the audience? From the intro:
It goes without saying that this book is not aimed at beginner PHP
developers and some object-oriented experience is assumed. Having said
that, of course, this is as gentle of an introduction as possible and represents
a beginner guide to functional programming in PHP.
Quite frankly, if you never had exposure to functional programming (FP) you won’t learn enough from this book.
My book recommendations
Rather grab one of these books (in increasing difficulty; btw all are available for free):
- How to Design Programs (HTDP)
- Concrete Abstractions (CA)
- Structure and Interpretation of Computer Programs (SICP)
Let’s say that you had some exposure to FP. It doesn’t matter if it’s a Lisp or Haskell or OCaml or whatever. You won’t need that book. Instead take a look at all these pages from the PHP manual:
I frankly don’t know to whom this book should appeal.
No real depth
There are several other problems – most were addressed by Stefan. It’s incredible shallow – I think it would have been a lot better if the author had spent more time on the language fundamentals. Dig into some C code and look how
array_filter() is implemented. Or something I loved in a lot of books I read on FP: Reimplement the language in the language. Go into detail.
An other thing, Stefan also addressed that, is that Haskell envy. It’s like physics envy:
In science, the term physics envy is used to criticize a tendency (perceived or real) of softer sciences and liberal arts to try to obtain mathematical expressions of their fundamental concepts, as an attempt to move them closer to harder sciences, particularly physics.
PHP isn’t Haskell. And as much as the author seems to love Haskell, it also isn’t the only way. Especially given PHP type system in comparison to Haskell’s. Maybe it would have been more interesting to work with a language that is closer to PHP than Haskell.
Missed chance and PHP isn’t ready, yet
There are two more things. On the one side I see a missed chance. The author could have taken a piece of code and refactored it using FP. Or could have shown how the development could differ (he even mentioned a REPL at the start). Maybe showed some potential bugs and how the vanish using FP.
The next thing, and I think that’s one important point, is that PHP isn’t ready, yet. All the more, I had shown how you can apply the ideas about FP to PHP. E.g. write code without side effects. Learn the power of higher-order functions, etc. He talked a bit about that but there was just that lack of detail. What a pity!
Conclusion / TL;DR
I don’t recommend the book. Read the books I linked if you are new to functional programming or just read the PHP Manual if you aren’t.