“ClojureScript Up and Running” (Book Review)

I’ve recently finished the “ClojureScript Up and Running” book by Stuart Sierra and Luke VanderHart. Here’s a quick review of it.

It opens with a quick introduction which attempts to present ClojureScript as the alternative to (or a matured “version” of) JavaScript. Then it immediately dives into gory technical details:

  • It shows how to set up a Leiningen project with lein-cljsbuild and explains the compilation process in detail (with all the possible parameters and modes).
  • It explains the development process – getting ClojureScript, working with browser REPL, testing, packaging for use with CLJS and plain JS applications.
  • It gives a basic introduction to the language, which really is a head-first guide to Clojure (though I suspect it’s far from enough for people who don’t know Clojure, and for those who do know it it’s no use).
  • It explains integration with JavaScript, but mostly on the level of Google Closure – exporting functions and namespaces for the world outside, or using external libraries with Closure advanced compilation.
  • It explains integration with Clojure, especially using EDN as an alternative to JSON.
  • It also introduces a few CLJS libraries (little code, just an idea of what a library does). Among others it includes C2, jayq, enfocus, core.logic, domina. Google Closure is on the list as well.
  •  

    There are many things I missed, though.

    First and foremost, it does not do enough to explain why we need ClojureScript. It does not really try to convince anyone, it’s pretty much a very technical “up and running” guide.

    It does not tell you how to write ClojureScript code. The explanation of setup, compilation and integration is great, but that’s all there is. Actually, there’s little about ClojureScript itself in the book. It’s like (unconvincingly) telling you that Java is the more robust and productive alternative to C++, showing how to use javac and Eclipse, “Hello World”, and a brief indication that there’s also JEE and Swing and this and that. I wish it had some case studies, chunks of actual ClojureScript code, some discussion of architecture, patterns, sample applications…

    One more thing I did not like is that it apparently ignores the JavaScript world (except for Google Closure). There are many rich and mature JavaScript libraries out there that solve many problems, and this book has not a word on the common ways to integrate them. I spent a good while experimenting with CLJS with Backbone, Knockout, Angular and jQuery, and it’s quite a difficult, frustrating task. I know I can write a CLJS library to do the same things that Knockout does, but I would prefer to learn how to integrate the existing library with my CLJS application to solve a real problem, or be introduced to a pure CLJS alternative that someone has already created.

    Perhaps it reflects the current state of ClojureScript – not yet very mature or stable, without mature and established libraries, patterns.

    All in all, I have mixed feelings. The book is very dense and concrete, and delivers much content on so few pages. It’s true to its title – gets you up and running, and does it very well. But then immediately leaves you alone in the woods. We are yet to see “The ClojureScript Book”.

2 thoughts on ““ClojureScript Up and Running” (Book Review)

  1. In my opinion some of the weak points you (correctly) point out are due to the book being published as a member of O’Reilly’s ‘Up and Running’ series, which intentionally adopts that format.

    Can’t judge the book itself as I haven’t got in my hands yet but I must say: a) cljs is pretty much Clojure (duh), so covering all its details would needlessly overlap with all the existing literature. And b) unfortunately while its ‘scene’ is pretty hot, cljs still has a long way till achieving the traction CoffeeScript currently has. So many aspects you would expect from a truly comprehensive guide, simply won’t / can’t be there.

    No bad feelings for your post, I just thought this had to be said. :)

  2. vemv – yeah, that’s why I say it’s true to the title and very good in those bounds.

    Just like there’s more to Clojure than just the data structures and list comprehension, there’s more to ClojureScript than just Clojure. It’s a different way of thinking and designing code. Let’s say that I’m willing to give CLJS a chance and try to understand enough to make my own point on *why* to use it. But I would still like a pro to show me *how* to use it, because I may be stuck in the JavaScript cave.

Leave a Reply

Your email address will not be published. Required fields are marked *

Spam protection by WP Captcha-Free