|Functional Thinking: Paradigm Over Syntax|
Author: Neal Ford
Audience: Devs who already know some functional programming
Functional programming is a hot topic and a book that helps you think like a functional programmer is a great idea.
However this all depends on the author being able to think like a functional programmer and being able to express those thoughts. This is a tough requirement.
This particular book is based around Java, Scala, Clojure and the JVM functional languages. It is aimed at a reader who already knows the basics of functional programming and wants to know more. The use of Java and Scala is justifiable in that they are both popular languages, but the key task is to use them to illustrate function programming ideas so that the book might be useful to the more general reader.
Although the book states that it is aimed at readers who know some functional programming, it isn't very clear exactly what they are expected to know. There are various grades of "knowing" functional programming from just stringing together some fluent function calls, to using lambdas and worrying about monads. This book isn't at the academic end of the spectrum and it doesn't go in for functional programming as typified by Haskell and its practitioners - you won't find any references to category theory or even the ever-trendy monads. Unfortunately you won't find much in the way of references to what makes functional programming special - pure functions and what this means in practice, i.e. immutability and minimal side effects. These core aspects of functional programming are not emphasised and are certainly not presented as motivating factors for adopting functional programming.
The first chapter is an introduction to the idea of functional programming but it isn't very convincing. Neal Ford introduces the idea of ceding control to the language/runtime - which is a programming trend but not one particularly associated with functional programing. Here we first start to get a flavor of the approach - a description of basic things rolled up into management speak slogans with little effective proof or indication of why things might be better.
Chapter 2 moves on to consider imperative versus functional programming and really doesn't explain the difference. An example of using standard functions such as filter, map and fold/reduce follows. You can use these without swallowing the whole functional idea and this is a very weak form of functional programming.
Next we have a chapter entitled "Cede". This book really does try to persuade you of the idea that functional programming is mostly about letting the language look after things that you would normally worry about. This is true for programming in general and no more so for the functional approach. Next we get an explanation of closures, Currying, partial application and recursion - none of which made any sense to me and I know what they all are. The explanation of the difference between Currying and partial application was particularly dense and left me wondering why a simpler example was used. The same is almost true of closure and there is very little explanation of how or why any of this might be useful. In particular recursion is just introduced as an alternative form of iteration - it is in fact iteration with a variable number of indexes.
Chapter 4 is called Smarter Not Harder and again we have an aphorism that applies to just about any approach to programming. In this case the topics are memoization and lazy evaluation. Again all simple ideas introduced in complicated ways with lots of cute quotes.
At this point I had lost patience with the book and almost gave up on it. Chapter 5 is called Evolve and its about some strange topics that are examples of "bending" the language toward the problem - functional polymorphism (i.e. multi-dispatch), operator overloading and functional error handling. Chapter 6 is about functional patterns, Chapter 7 is about Java 8 and the final chapter is about polyglot and polyparadigm programming.
There might be something worthwhile in these chapters. but it would be hard work digging it out. Much of the book seems to be about showing programmers familiar with object-oriented techniques and the "patterns" approach to programming how functional programming can be seen in a similar way.
This book is full of cute sounding quotes, the sort beloved of management, confusing explanations and very little about functional thinking beyond the surface details of the languages used as examples. You might get something out the comparison of the different JVM languages and how they approach functional programming, but only if you already know what functional programming is all about at a reasonably deep level.
If you are serious about appreciating functional programming then you need to look for a different book.
|Last Updated ( Sunday, 16 November 2014 )|