found drama

get oblique

review: Clojure Programming

by Rob Friesel

Clojure ProgrammingIn Clojure Programming (Chas Emerick, Brian Carper, and Christophe Grand; O’Reilly, 2012), the preface asks Who is this book for? It’s for a lot of people: experienced JVM developers, curious Rubyists, dissatisfied Pythonistas… Developers of all stripes that are looking to get introduced to, and become proficient in, Clojure. I myself have been circling the Clojure drainpipe for a while now, very nearly getting completely sucked in on numerous occasions. I’ve followed no one’s advice though–I have not started small, and instead keep jumping into sophisticated middle parts and getting mired.1 I think I would have benefitted from this book a year ago; I’m certainly benefitting from it now.

At 587 pages2, Clojure Programming is hardly a tome, but it is comprehensive, appreciably thorough, and makes a concerted effort to be accessible to the Clojure and JVM neophyte. That being said, the book is also far from short, and makes no pretenses about easing you into the language: you’ll be programming a naïve REPL by the end of chapter one. But this head-first approach is one of the reasons to love this book.

Emerick et al. found an excellent format for organizing the book, logically sequencing the material, and peppering chapters and sections with the right kind of illustrative, koan-style sample problems, eschewing the alternative of walking you through some contrived and over-arching application built one concept (and thus one chapter) at a time. As such, the book is broken into five sections:

  1. Functional Programming and Concurrency (the foundation);
  2. Building Abstractions (the sophisticated stuff);
  3. Tools, Platform, and Projects (the eco-system);
  4. Practicums (Clojure in the real world); and
  5. Miscellanea (other important stuff).

What’s marvelous about this structure is that you can decide for yourself whether to read it cover-to-cover, or whether to cherry-pick just the chapters relevant to your immediate challenges. What’s helpful is that the book cross-references itself for many key concepts. In the thick of chapter one and you don’t know what this “classpath” nonsense is? Jump ahead to chapter eight!3 Deep into chapter nine and you’re lost about how Clojure protocols relate to Java’s interfaces? A footnote steers you back to chapter six! The care taken to create these kinds of cross-references is tremendously valuable because it allows you to opt-in to some advanced concepts early on, getting a preview of the powerful features ahead of you.

Though Clojure Programming is overflowing with thoughtful, detailed, and well-composed information, where it really shines is the “Practicums” section. When I first started skimming the chapters in this section, the first thought that occurred to me was: “Herein lies the true esoterica.” I read about Clojure’s numerics and mathematics, about its intriguing use of “rationals”, about unchecked operations. I read about how to idiomatically implement different design patterns in Clojure. The deeper I got into this section though, the more that I realized that this was not a bunch of “out there” riddles and puzzles whose only purpose was to show off the sparkling fringes–no, this section was to demonstrate Clojure’s solutions to “real world” problems, and the kind of advantages afforded you by its functional style.4 That being said, I appreciated how Emerick et al. were vigilant in observing when different approaches or language features would serve you well, and when you would be wise to avoid them.

A few other items that I feel compelled to point out:

  • The chapter on Java and JVM interoperability is strong. Anyone looking to introduce Clojure into their (JVM-based) organization would be wise to memorize this information…
  • …and then also memorize the chapter that specifically addresses how to go about introducing Clojure to your organization.
  • As with the other Clojure texts I’ve read, their is a focus on discussing “idiomaticity”, and differentiating between “working” or “valid” Clojure code, and idiomatic Clojure code. Seeing this again makes me wish that more authors writing about other languages put this much emphasis on idiomatic style.
  • Also, I am filled with tremendous gratitude that Emerick et al., when they cite Wikipedia at all, cite particular articles as “a jumping off point” or as “a surprisingly good resource” for the subject matter. I have read several books recently that cite Wikipedia as an authoritative reference and… Well, I find that to be in bad form.

I find it easy to recommend Clojure Programming to anyone with an interest in the language. There is enough “introductory” material that smart programmers will be guided in the right directions as they get started, but there is also enough detailed coverage that the book will grow right along with you. The chapters on the Clojure eco-system will help to steer you toward the right tools and resources to organize, manage, and scale your projects–as well as how to integrate them laterally within the JVM. Lastly, the practicums give you concrete and balanced approaches to answering some of the questions that you go into the whole endeavor already asking. I will be referring to this book often as I continue my explorations into Clojure.

Disclosure: I received an electronic copy of this book from the publisher in exchange for writing this review.

  1. Case study: the first significant chunk of time I spent with the language was with early drafts of The Joy of Clojure. JoC is definitely an “intermediate-to-advanced” book. []
  2. Not counting the preface and index, which brings that up to 630. []
  3. Which, I’d like to add, is currently my favorite semi-layman’s explanation of the JVM’s classpath. []
  4. I suppose this should have been obvious from the name of the section. (What can I say? I got caught up in the details of rational numbers.) []

About Rob Friesel

Software engineer by day, science fiction writer by night. Author of The PhantomJS Cookbook and a short story in Please Do Not Remove. View all posts by Rob Friesel →

One Response to review: Clojure Programming

Leave a Reply

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