Practical Clojure

Author: Luke VanderHart & Stuart Sierra
Publisher: Apress, 2010
Pages: 350
ISBN: 978-1430272311
Aimed at: Programmers wanting an introduction to Clojure
Rating: 4.5
Pros: Highly readable, good level of explanation
Cons: Lacks convincing examples
Reviewed by: Mike James

The title might leading you to expect some real world examples - does it deliver?

Clojure is a Lisp like language that runs on the JVM which means it works almost anywhere. I am a Lisp enthusiast but I get very few chances to make use of it these days because it just isn't regarded as a modern language. Clojure is therefore a welcome change from my usual diet of object-oriented programming. I have to admit that I don't really understand the cover lines -

"Full introduction to Clojure, a full Lisp variant for the JVM"

What does "Full Lisp variant" mean?

It is also difficult to read the book and avoid blaming it for the shortcomings of Clojure. At various points I almost cried out in horror at the thought of an innocent object-oriented programmer trying to cope with the comparatively primitive and very alien environment that is Clojure. Not only do you have to struggle with functional programming Lisp style, no objects, a persistent environment and nothing but recursion but Clojure is still a very young and immature language. The authors do their best to explain the thinking behind the philosophy and they don't just present the syntax and an example of the semantics they do attempt to explain how you should approach a problem using Clojure.


Banner

Chapter One does a good job of outlining Clojure's history and place in the world. This where you first meet functional programming and Clojure's approach to state management.  Chapter 2 gets you to write a Hello World program and starts introducing you to the basic syntax. To see how far the Clojure world is from common object-oriented programming I asked a C# programmer what they understood by:

" the fundamental unit of a Clojure program is not the line, the keyword, or the class, but the form."

The response was predictable "do you mean the fundamental unit is a thing with buttons and textboxes?" Of course here "form" means "logical form" as in expression, something you can evaluate. No comment is made in the book and why should the authors expect that there could be any confusion over perfectly standard jargon, but it does go to show just how different the worlds of C# and Clojure are.

Chapter 3 is about controlling program flow and this is where you are introduced to the next shock - no loops. This is a good introduction to the functional recursive way of doing things. It would be better if more time had been spent explaining how recursion fits in with immutability and creating new copies rather than updating the old.

Chapter 4 moves on fairly quickly to a very plain and straightforward presentation of data  types - but of course type isn't quite the right word as Clojure doesn't do types. Chapter 5 continues with sequences and specifically spends a lot of time on lazy sequences - an implementation point that can make Clojure difficult for a beginner.

Chapter 6 moves on to the big topic of the book - state management. Here we are treated to the initially complicated way that Clojure lets you do something apparently as simple as updating a value. The book explains it well but at the end you have to wonder if this amount of internal machinery should be showing in a modern language.

From this point on the book deals with secondary topics that you have to know about but aren't really core to the language. Chapter 7 is about namespaces and libraries; Chapter 8 deals with metadata; Chapter 9 introduces multimethods - Clojure's way of doing polymorphism; Chapter 10 deals with Java interoperability; Chapter 11 is on parallel programming; Chapter 12 is on macros and meta programming and Chapter 13 is on datatypes and protocols. The final chapter looks at the real world problems of performance and optimization.

This is quite a good book and ideal if you already have some idea about Lisp or functional languages in general. It explains the details of the language very well what it fails to do is to give you the broader view. While I don't like over big examples in a book that is introducing difficult ideas ,a few medium sized examples of how you would tackle a familiar problem would have helped.

After reading, say, 75% of the book you are left with a feeling that you understand the language but don't really have much understanding of why you might want to use it or what it is really good at. Yes, you are clear that it provides a better way to do parallelism without locking, but what else can it do?

Overall, the book is great at explaining the ideas and for this the mostly tiny examples work perfectly. What it lacks is the bigger picture of using Clojure in a real project - it's a bit narrow. If you can cope with this omission, either by already knowing or finding out from another source, then this book comes highly recommended.

Banner


Understanding Software Dynamics (Addison-Wesley)

Author: Richard L. Sites
Publisher: Addison-Wesley
Pages: 464
ISBN: 978-0137589739
Print: 0137589735
Kindle: B09H5JB5HC
Audience: Every developers
Rating: 5
Reviewer: Kay Ewbank

This book looks at the different reasons why software runs too slowly, and what developers can do about it, starting by looki [ ... ]



Continuous Architecture In Practice (Addison-Wesley)

Author: Murat Erder, Pierre Pureur and Eoin Woods
Publisher: Addison-Wesley
Pages: 352
ISBN: 978-0136523567
Print: 0136523560
Kindle: ‎B08ZRTQGLJ
Audience: Software Architects
Rating: 3
Reviewer: Kay Ewbank

This book sets out the case for why software architecture is more important than ever, and in p [ ... ]


More Reviews

Last Updated ( Tuesday, 10 May 2011 )