Book Review: Clojure for Domain-specific Languages

I’m clinging to the excuse that I had only read the title of the book before volunteering to review it. If I had even got as far the sub-title, I would have thought twice.

Clojure for Domain-specific Languages cover

The title hints at something interesting; building a DSL in Clojure.

However, the subtitle – “Learn how to use Clojure language with examples and develop domain-specific
languages on the go” – is where it all begins to fall down.

Ignoring the grammatical error, the first half of the sentence tells you that this is a book for Clojure beginners. The second half tells you it is a book for developing DSLs (apparently “on the go”, which I can only assume is intended as a synonym for “quickly” or perhaps “in the context of larger programs”).

A few pages into the book things get worse. Some familiarity with Clojure is assumed in chapters 1, 2 and 3, which is odd given that Chapters 4 to 8 are a beginner’s introduction to Clojure that has little to nothing to do with DSLs. There is a chapter on building a Twitter DSL, before it’s back to a chapter on Clojure testing (nothing about DSLs here) and the book finishes with a chapter on how to call Clojure from Java.

The major problem is that I just can’t imagine who would want to read this book. There are much better resources for learning Clojure and the stuff on DSLs is so thin it feels tacked on. It actually left me in a bit of confusion as to what a DSL really is – most of the examples given feel more like libraries than specialised languages.

I’m afraid I have very little positive to say about this so book, so rather than go on and complain about things like characterising ClojureScript as a Javascript DSL or the amount of time spent discussing indentation, I’ll end with an imaginary transcript of the phonecall between author and publisher that brought this confused book into existence1.

Publisher: “Hey, Ryan, how’s the book coming on?”
Ryan: “Great, nearly done. I’ve just added a great example on a twitter DSL.”
P: “OK. Here’s the thing – the market for intro to Clojure books is saturated. There’s half a dozen titles including free ones. I just don’t think we can sell it.”
R: “What? I’ve sunk 6 months of my life into this!”
P: “Don’t worry, we just need to put a spin on it – appeal to a different market. What was the example you just wrote again?”
R: “A twitter DSL”
P: “Perfect! Just we’ll just rename the book Clojure for Domain-specific Languages and get all the DSL weenies to buy it. Write a chapter on DSLs to start the book and get it back to me in a week.”
R: “Err, I’m not…” <click, bzzzz>

  1. This transcript has no basis in reality and is just a bad attempt at humour to lighten the tone. I feel pretty bad about writing this review as I have a lot of respect for anyone that manages to write and publish their own book. Unfortunately this one just isn’t very well thought out.. []

Leave a Reply