Channels ▼

Mike Riley

Dr. Dobb's Bloggers

Programming Clojure Book Review

August 20, 2009

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

 

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video