TechBookReport logo



Keywords: Clojure, Lisp, functional programming

Title: Clojure Made Simple

Author: John Stevenson

Publisher: Developer.Press

ISBN: .

Media: Book

Level: Some programming assumed

Verdict: A fast and efficient introduction, though perhaps a bit too brief at times

 

There can be no denying the spike in interest in the latest generation of Lisp-like languages - including Scheme, Clojure and a relative new-comer Racket (and for those interested in the latter, take a look at our review of Realm of Racket for the gory details). Far from being consigned to history, Lisp is back in vogue, unlike some of the other languages that emerged in the same era (such as APL, for example). In my humble opinion, a good part of this renewed interest is thanks to Java. The Java run-time environment is pretty much everywhere - as a platform it's solid, offers pretty good performance and is well-supported. Building new languages on top of the run-time has really mushroomed in the last few years, so there's no surprise that in the profusion of languages exploiting the Java Virtual Machine there are some Lisp-flavoured ones like Clojure. But it's not just the run-time, the computing environment that the run-time operates in has become more complex too, particularly with the rise of increasingly parallel computing. Java the language can support concurrent programming of course, but the whole object oriented paradigm becomes more difficult when you have to worry about data mutability all the time.

All of which is to say that part of the attraction of Clojure is that is handles concurrency in a much more natural way than Java does. And for those who are looking for that fast introduction to the language, John Stevenson's 'Clojure Made Simple' has a lot to offer. For starters this really is a brief introduction - the page count doesn't make 50. This means that the explanations are stripped down so that you only get the core essentials of the language. This means no extended examples, no forays into theory and only a skim on any deep level of detail. But it's enough to introduce the language and make clear the different philosophy that underlies it - Closure is a functional language based on Lisp, and these are the key features...

The opening chapter makes a stab at explaining why you should be interested - which is a good place to start a new language. The assumption here is that you are an existing developer, this is not a book aimed at the absolute newbie (and I'll refer readers to Realm of Racket if that's what you're looking for). Aside from things like concision and leveraging the Java environment the author right homes in on data immutability, which makes this different to Java, C#, Python et al, and which makes writing concurrent code much more straightforward.

The next chapter introduces a Clojure programming environment - in this case it's called Leiningen - and shows how you can use this to get yourself a REPL (read evaluate print loop) so that you can explore the language dynamically. It's in the third chapter that you really start getting to the core of the language, with introductions to the functions, lists, vectors and maps. The examples are all simple, but enough for you to follow along and try things out. If you've never had any exposure to a functional language or to Lisp before then time spent in this chapter will pay off as it really gets to the core of the language. This is followed by a chapter on Clojure types, including showing how these types ultimately resolve to the underlying Java types. In this chapter you also get to work with the idea of functions using functions as data - higher-order functions in other words - and you are introduced to the concept of filter, reduce and map, which are key concepts in Clojure (and other similar languages). This is one of the parts of the book that could have done with some more complex or realistic examples, while the concepts are introduced and explained well enough, for those coming to Clojure from more traditional languages some extra content would probably be beneficial.

Chapter 5 covers a mix of topics - program flow, namespaces, loading files into REPL It's bitty and lacks cohesion. Similarly with the final chapter that looks at things 'behind the scenes' - specifically at vars and macros. These final two chapters really don't work all that well, even though individual topics they cover are important.

Overall this does deliver a fast introduction to the core language. The explanations are clear and concise, just like Clojure itself. However, the concision does mean that this is a fairly light introduction. The text could have done with additional examples and a little bit more depth in places. Learning a new programming paradigm takes more work than learning a new language in the same family as one you already know. Given that many of the people looking at Clojure for the first time are likely to be coming from object oriented languages then some additional content to help them would make this a more useful book.


Hit the 'back' key in your browser to return to subject index page

Return to home page

Contents © TechBookReport 2014. Published January 23 2014