Publisher: ManningPages: 432ISBN: 978-1935182597Aimed at: Java and Ruby programmers, in particular those already working with ClojureRating: 3.5Pros: Comprehensive and practicalCons: Doesn't do a good job of explaining ClojureReviewed by: Mike James

Clojure seems to be getting a lot of attention at the moment. Is an "in action" approach a good way of finding out about it?

Clojure is a dialect of Lisp for the JVM - hence it is attracting attention from Java programmers who really only know the object-oriented way of doing things. The book's back jacket says

"This book assumes you're familiar with an OO language like Java, C# or C++ but requires no background in Lisp or Clojure itself."

I have a "background" in Lisp in that I used it for a number of AI projects, and as a result I have admired the language for a long time for its economy and power. What puzzles me about Clojure is that it claims to be helpful in situations where I would not think of using Lisp, simply because the freedom of expression it provides is not needed and may even be counter productive.

Part 1 of the book is Getting Started and Chapter 1 is an introduction to Clojure. Essentially this is just a history and an overview of where Clojure fits in as a JVM language. From here we have a "whirlwind tour". This is a basic guide to installing the language and using it. The big problem is that it presents the syntax and semantics of the language in a way that is superficially easy but if you don't already have some idea what makes a language like Lisp special then you are probably going to be left behind. It tries to get across a flavour of the language but without really explaining the grand plan. In general the a topic is introduced with a small program which is then explained as a specific example of a general principle that you are suppose to extract from the description It would be much more efficient to present the general principle and then show a few examples.

By the start of Chapter 3 you have seen if not absorbed or fully understood a great deal of Clojure. Next you start to look at the details - functions, scope rules, namespaces and so on. Chapter 4 introduces multimethods as a key feature in building a Clojure program even though my feeling is that most readers will not have much idea as yet what such a program would be like.

Chapter 5 deals with Java and Clojure interop. While this is an important real world topic, I felt I hadn't really got to grips with Clojure before starting to worry about interop. Chapter 6 deals with state management, which is a particular puzzle for anyone new to functional languages with their immutable data objects. This chapter does a very good job of explaining why immutability is good if you are using any sort of multi-threading. However, you still need to learn quite a lot to make it all work and it is arguable that many similar methods are used in object-oriented languages to control access.

The final chapter of the section is on using macros. This is arguably the most dangerous feature of Clojure. If you fail to see how to keep such a feature under control and organized then the result is a program that is impossible to understand. Of course, if you take to it then you can turn the whole approach into a methodology and do little else but create Domain Specific Languages (DSLs).

At the end of Part 1 we are now expected to move onto Part 2, which deals with applications of Clojure. Personally I felt I hadn't had a good enough introduction to the language to enable me to do so - and I knew Lisp before starting the book. My guess is that you need to have met and worked with Clojure and at least started to understand its particular strengths in not distinguishing too clearly between data and program.

If you do know Clojure then the second part of the book will be useful to you. It starts off with the ever-trendy topic of test driven development. Chapter 9 is on using Clojure with MySQL, HBase and Redis. Then we have a chapter on web programming - HTTP, Ring, Compojure, and raw HTML. Chapter 11 is on messaging systems - JMS, STOMP, RabbitMQ and so on with an overview of how to use message passing as a way of implementing distributed parallel processing. Chapter 12 is on data processing but perhaps not what you might expect but on map/reduce and master/slave parallelism.

The final three chapters form a sort of advanced look at Clojure with functional programming, macros and DSLs taking center stage.

This is a well written book but it does assume a level of understanding that a reader coming to it to actually learn Clojure from scratch probably wouldn't have. It also isn't an easy read the style of presentation means you have to read some sections more than once to try and see the general from the specific example.

If you have an idea what makes Lisp like language special then you might get something from Part 1 sufficient to be able to find Part 2 of use. If you haven't a clue what is going on, and find the way that data and program are one and the same, recursion and immutability all a mystery, then I would suggest a gentler introduction to Clojure. It certainly isn't going to win any converts from Java programmers who pick it up just to see if Clojure has anything to offer.

This book is going to be most effective if you have already left the starting blocks and want to see how Clojure fits with other systems and real world tasks. If you fit this description then you will find this an interesting read.