Book Review: Beautiful Code

I finished reading “Beautiful Code” from O’Reilly press a couple of weeks ago. (592 pages). “Beautiful Code” is a collection of essays that attempt to capture code at it’s most elegant. They subtitle being “Leading Programmers Explain How They Think”.

I never really thought of code as potentially beautiful so the title caught my attention right away. What kind of code would they present to be called beautiful? While there were some interesting ideas presented there were no bright flashes of beauty.

The subtitle was more misleading. Some of the essays did attempt to explain what the author was thinking when creating a particular design. The majority of the essays, however, skipped this interesting conceit entirely. Many of the essays could have used some insight into the programmer’s thought process because the code in and of itself wasn’t all that interesting.

I don’t want to give the impression that I didn’t like this book. On the contrary, “Beautiful Code” was a very novel approach to what can be a very dry subject. Many of the writers were able to inject a sense of purpose and passion into their discussions that was refreshing. Too many times with a book about code authors spend all their time talking esoteric coding “magic”.

The discussion on Google’s use of the MapReduce algorithm was pretty cool. The problem of efficiently searching for words found in every known searchable webpage has always fascinated me. I knew it must be a parallel algorithm. What I didn’t know was the algorithm used at Google was designed for general purpose computations. I always assumed Google wrote a special purpose system; optimized and targeted at search.

There was a topic on the design and implementation of the Linux kernel driver architecture. It was enlightening to see inheritance implemented in strict C. I knew it was possible but really hadn’t given the idea much thought. After reading this topic, however, I see a very useful and extensible design.

One topic talked about a ‘Spoonful of sewage’. The idea being you only have to introduce a little bit of garbage to ruin something completely; like a spoonful of sewage added to a barrel of wine. The theme concerned finding a bug deep in the guts of the Solaris OS. I really appreciated the insights not only into the code but the thoughts and hard learned lessons behind the code. In the end it took a very small change to introduce a very nasty and hard to debug problem into the system.

The languages used in each topic varied; from standard C++ and Java, scripting languages like Perl and Ruby, and functional languages like Lisp and Erlang. This variety of languages was refreshing and really points to the old saw about selecting the appropriate language for the job at hand.

All in all I did enjoy this book. The one problem I had with the book was consistency. The editor gave each author a lot of flexibility to discuss whatever they wanted to write about. This left some topics that were really insightful, some were light on details and heavy on ‘concepts’, while others seems simply self aggrandizing. From what I recall there were two chapters dedicated to basically the same technology. I wish each topic was more focused on the author’s thought processes and presented more lessons learned in the trenches.

You might have to pick your diamonds from the coal with this book. In the end I found “Beautiful Code” a worthy read.

Tagged with: ,
Posted in Uncategorized
Design a site like this with WordPress.com
Get started