Programming Clojure Book Review
Fifty pages longer and two dollars less expensive than Pragmatic Bookshelf's Programming Scala, their Programming Clojure book presents an alternative manifestation of a concurrent JVM-hosted language. Is this book's presentation enough to sway Lisp fans to the Clojure camp? Read on to find out.
Written by Stuart Halloway, author of several Java-centric titles including Rails for Java Developers, Programming Clojure provides a straight-forward overview of this Lisp-like JVM-hosted language. The book's Foreword is written by Clojure's creator, Rich Hickey, bemoaning the rise of complexity in software development and the need to return to simplicity via a functional programming approach. This message sets the stage for the remainder of the book, and the author succeeds at showing the elegance of simplicity in Clojure's interpretation of a better Lisp.
The first chapter helps readers locate, download and set up a Clojure development environment via the read-eval-print loop (REPL) launch script. Chapter 2 explores Clojure forms, reader macros, functions, bindings and name spaces, flow control and metadata giving plenty of REPL examples to help illustrate Clojure's syntax and powerful design. Chapter 3 on Java interoperability covers importing and calling Java classes and collections, performance optimizations and exception handling. Chapters 4 through 6 cover the most compelling aspects of Clojure, including data/library sequencing (both lazy and infinite), an excellent introduction to functional programming, Clojure's trampoline function (calling upon a technique for optimizing mutual recursion), its Software Transactional Memory (STM) that uses a technique known as Multiversion Concurrency Control (MVCC), dealing with transactional agents and per thread states, dynamic binding and macros. These techniques are demonstrated in a Swing-based snake game (cross your snake's body during a hunt for the apple and you lose).
Chapter 7 covers one of Clojure's most powerful features, Macros. As the author states in his rephrasing of the frequently quoted line from the movie Fight Club, "The first rule of Macro Club is Dont Write Macros" followed by "The second rule of Macro Club is Write Macros If That Is The Only Way to Encapsulate a Pattern". The remainder of the chapter initiates readers into Clojure's Macro Club, concluding with the construction of a Lancet (Clojure's build system that works with Ant) DSL. Chapter 8 on Multimethods provides Clojure developers with a more general polymorphism model. I appreciated the author's comments on when and when not to use multimethods. Finally, the book concludes with Chapter 9, Closure in the Wild. The author addresses questions like writing unit tests, accessing databases and building web applications, illustrating how Clojure's flexibility offers numerous ways to solve these inquiries.
Programming Clojure is certainly a worthwhile book for any Java and Lisp enthusiasts to read. Its meta macros, lazy sequences, powerful concurrency library and expressive DSL support are very attractive from an academic perspective and I foresee the language being strongly considered as a Lisp enhancement or replacement in some Computer Science curriculums. While its functional programming Lisp-like dialect may take a bit of energy to digest, the rewards could be quite fruitful, as was recently the case with FlightCaster's Bradford Cross upon mentioning Clojure's use in his company's predictive flight delay modeling web application. Clojure may not appeal to everyone, but to those who are open minded to trying a new approach, Programming Clojure will open new programming horizons and a deeper appreciation for the elegance it has to offer.

Title: Programming Clojure
Author: Stuart Halloway
Publisher: Pragmatic Bookshelf
ISBN: 978-1-93435-633-3
Pages: 304
Price: $32.95 US

