Book Review: Clojure Data Structures and Algorithms Cookbook

Clojure Data Structures and Algorithms Cookbook (Packt Publishing / Naccache)

Clojure Data Structures and Algorithms Cookbook (Packt Publishing / Naccache)

The term ‘data structures’ is sort of an emotive word in the world of purely functional languages as the subject of data structures and algorithms in classical (imperative) computing relies on mutable variables and assignment which are not possible (or at least discouraged) in functional programming. This topic has been addressed in Chris Okasaki’s PhD thesis, where he discusses purely functional data structures. Since then, a couple of new data structures have been developed, all of them highly sophisticated and really nothing for a student at entry level. Long story short: the treatment of data structures and algorithms in the functional world requires different approaches and procedures.

Rafik Naccache neither reinvents the wheel nor does he develop new functional data structures in his book ‘Clojure Data Structures and Algorithms Cookbook’. Instead, he uses the functional approach of Clojure for meeting several algorithmic challenges with real-world use cases. And his book covers a wide range of fields, starting with classic data structures like arrays (data compression, fractals, stacks), lists (doubly linked xor lists, shift-reduce parsers, random access lists), several variants of trees, decision and optimization problems (recommendation engine, optimal path, text summary), logic programming, communication tools, and inherently functional developments like a recursive descent parser, a firewall simulator and a symbolic expression unification engine. The plentitude of topics suggests the up-to-dateness of this book, and even if one won’t read it from start to end the reader benefits from this collection of implementations.

The book’s structure is optimized for fast reading without compromising the details. After an introduction to each topic and its theory the author discusses his implementation and provides a sample usage of what has been developed. This way he covers the complete development process from theory to testing. Further information links to (mostly scientific) papers by the author(s) of the appropriate algorithms. Naccache’s code works well and is surprisingly concise; a hint that his collection of programming challenges works very well with functional programming languages.

This book is no cakewalk, though: the reader should have at least intermediate knowlegdge of Clojure and a strong interest in the topics covered. This book strongly reminded me of a ‘Numerical Recipes’ book, written for Clojure programmers in a terse and exact style. Recommended.

Clojure Data Structures and Algorithms Cookbook, Rafik Naccache, Packt Publishing, August 2015, 216 pages

About Manfred Berndtgen

Manfred Berndtgen, maintainer of this site, is a part-time researcher with enough spare time for doing useless things and sharing them with the rest of the world. His main photographic subjects are made of plants or stones, and since he's learning Haskell everything seems functional to him.