Sunday, July 01, 2012

Book Review: Clojure Programming by Emerick, Carper, and Grand


Clojure ProgrammingClojure Programming by Chas Emerick
My rating: 4 of 5 stars

When I first started reading Clojure Programming, the first impression I had was that I've never seen a programming language introduction try so hard to tell me that my programming skills are going to grow significantly as a result of learning this programming language. This book is probably not for beginners, but working through this gives insights into why certain programming constructs work the way they do and how functional programming constructs fit with someone who is used to procedural and object oriented programming. While the efforts it makes to declare its superiority towards other languages gets annoying, the practice in using the REPL actually helps me understand how to better use tools I use in other languages.

My background is in scientific computing. And while I have used some standard languages such as Java, C, C++, and even Fortran, my first choice in languages tends to be either R or Python. The R environment is admittedly ugly, but in Python I typically use tools that surround the scientific ecosystem of ipython/Numpy/Scipy/Matplotlib. My programs tend to be structured into a data gathering and manipulation portion (MVC) then an analytics portions dominated by a series list comprehensions and map-apply and finally presentations of results. In this context, I first heard of Clojure because the Incanter: Data Sorcery project, which was an attempt to create a Lisp-based statistical computing and graphics platform. So I approached Clojure Programming with a view of its suitability for technical computing, or a way of learning functional programming techniques in a deeper fashion for use in R or Python data analytics.

It somewhat disappoints in this. When Clojure Programming put effort into demonstrating its unique points, such as the REPL, I kept on thinking "I already have this in Python/ipython" (in particular the ipython shell gives considerably more capability than the standard shell) When reaching the Numerics chapter, it seemed to be a discussion of standard data types (and when trying to discuss Python numerical types, not acknowledging Numpy data types and discussing performance is ignoring the real world.) My main complaint is that the discussions of language and environment features feels like I'm being presented with a long list of details, without having first having a general sense of what programming would be like.  In many ways, it is similar to learning scientific programming in Python.  You generally learn general programming first, and later on you learn the techniques for data analysis, many of which are based on functional programming practices.

What the book does well is explain deeply the principles behind the language and functional programming.  In works through them with cross references in the text wherever they are necessary.  And it explains why these principles are useful.   In particular with the REPL, which if I had not had experience with the ipython shell would have been quite different then other shells.

What this leads me to conclude is that this book would be very good for someone with a solid grasp of Java programming, with its ecosystem and libraries, and wanted to move into functional programming.  Clojure Programming provides a different workflow since it does compile/evaluate as you go, allowing you to see quickly the results of changes without any performance penalty. And having a different programming paradigm than object-oriented adds a set of tools that can be brought to bear under a different situation.

This was not quite what I was hoping for, but that may be because the tools and language features of Python/ipython were already overlapping with Clojure.  It does fulfill the promise of making me a more knowledgable programmer.  And I hope that working through Clojure Programming also makes me a better one.

Disclaimer:  I received a free electronic copy of Clojure Programming as part of the O'Reilly Press Blogger program.

I review for the O'Reilly Blogger Review Program
View all my reviews

Post a Comment