This book is mainly for computer scientists, not so much for engineers. The emphasis is first and foremost on theory and it didn't provide enough practicality for me.
The choice of language for this book -- Standard ML -- is in line with the above: Standard ML is used in research but not as much in the industry as other languages like Haskell, Erlang, Clojure, Scala. How many people are you reaching with this choice? True, there is Haskell source code at the end of the book, and sure I can think of the reason why SML was chosen (being defined formally in a very concise way, leaving out implementation details, etc) but still, I can’t shake the feeling that this choice is somewhat elitist and limiting.
Plus SML is not even a pure functional language!
The other problem I have with this book is that the “purely functional” part of the title doesn’t come out as clearly as I wanted to. Could be it’s just me since I mainly code in OO languages, but after the first 3 chapters there’s a lot of data/state manipulation which resonated more as imperative than functional to me. (After all SML has some imperative features.) The initial chapters instead spent time bringing this out, and those are the ones I enjoyed the most.
I did take away something though:
- the explanation of persistence vs performance was cool. At first this was confusing because what they refer to as persistence I call immutability. So, persistence requires that (e.g.) when joining 2 lists into one, the original lists need to be unchanged even if the joining operation should be performant. This requires copying the original lists but in practice only parts of the lists need to be copied. Very cool.
- There’s a good run-through data structures I never once used professionally (binomial heaps, leftists heaps, red black trees, splay trees, …) so it was nice to read about them.
- The explanation of amortization: for some collections where we need to perform some kind of processing on each item, we may not care if one item takes O(log n) or even O(n) as long as the overall computation is still O(n).
- After studying the persistence + memoization + lazy evaluation + amortization theory it applied it to a queue implemented as 2 lists (front and rear), rotating its elements to amortize the cost of each insert/delete/etc operation to O(1). I didn’t have the time to dive deep into this but it’s something it’d be cool to do one day... If they ever translate this book to Erlang or some other purely functional language!