rplevy

web log

Review: Clojure High Performance Programming

If you happen to be a software engineer who uses Clojure in production or in any serious capacity, I would recommend getting a copy of “Clojure High Performance Programming” by Shantanu Kumar (2013, Packt Publishing). A valid worry when discovering any new Clojure book is, will it be “yet another Clojure beginner book”? The answer to that question in this case is almost definitely a “no”, however for the hardcore JVM performance expert it may be a little slow-moving. From my perspective however, as someone who has had several years of experience developing high-performance distributed systems in Clojure, I found it to be quite valuable and informative. The book is a short but consistently high-quality 133 pages of substantive facts, useful reference tables, and accessible documentation of contemporary best practices for high-performance design, optimization, and profiling. As one might expect from the title, it is thoroughly grounded in real-world practice; there are only a few Clojure books in that category, and I would venture to say that this one is the best yet (as far as Clojure books in general go, The Joy of Clojure is the best book-length articulation of the Clojure idiom).

The first chapter defines common terms as they are to be applied throughout the book, and also introduces a theme that is revisited throughout the book, of performance modeling, objectives, and planning as being of fundamental importance in developing high-performance systems. Chapter 2 explores the performance properties of Clojure-specific abstractions (including a great table of algorithmic complexities of common operations on Clojure’s persistent data structures), whereas Chapter 3 does the same for Java-level abstractions. Chapter 4 presents an overview of modern hardware architecture followed by an in-depth discussion of the JVM, which leads into Chapter 5, the concurrency chapter, which in addition to being the best performance-focused treatment on concurrency and parallelism in Clojure/Java I have seen in one place, might easily be the most thorough treatment of Clojure/Java concurrency and parallelism features and data structures I have seen, in one place. And not least of this is a discussion of reducers, a topic that for whatever reasons has not been explored much beyond Rich Hickey’s somewhat opaque inaugural articles (I will admit to having used reducers, and having used them effectively, without fully understanding their implementation, much less Rich’s master plan— but I now have a somewhat better grasp of reducers). Chapter 6 and 7 explore performance analysis, optimization, and design at the unit, application, and system architectural levels.

The approaches described here are very much in keeping with my own experiences, but yet even where it was covering well-trodden ground, I found it valuable to read and learned a great deal. The bottom line is this book does a really good job of covering and conveying nuances of some interesting performance topics, and I think it is a great and much needed addition to the available selection of books on Clojure.