Book Review: Beautiful Code

Beautiful Code, subtitled ‘Leading Programmers Explain How They Think’ is a collection of thirty plus essays by some of the top programmers around today. names like Charles Petzold and Brian Kernighan should be recognisable to any developer but many of the others may be less familiar but nonetheless have much to offer.

It’s also worth noting that all royalties from this book go to Amnesty International so hats off to all concerned for their generosity and efforts.

As the title suggests, this book is about code. It can be beautiful in any number of ways and each contributor explores a particular subject and provides code examples to illustrate a language construct, algorithm or principle that they hold to be beautiful. As an example of the developer’s craft at its finest, this book can’t help but impress.

Where it falls down somewhat for us is that much of the subject matter is rather esoteric and I suspect the majority of developers will go through their entire career without needing to worry about summing the bits in an arbitrary word. Self-taught programmers without the benefit of a Computer Science degree will probably struggle with much of the content but perhaps that’s not entirely the point of the book.

Firstly, this is most definitely not a book for reading through at the same pace you would most programming guides. The ideas, the code and the concepts usually require much thought and analysis on the part of the reader to really appreciate. This reviewer has twenty five plus years of commercial developer experience across dozens of languages and I found much of it pretty dense. It also gave me my first exposure to languages such as Haskell and MATLAB.

Even if much of the content may be somewhat heavy, what is far more accessible, in the main, is the discussion that accompanies it where the programmers describe their thought processes, reasoning and techniques for solving the problem. Here there is much great wisdom and for this alone, the book deserves close scrutiny.

Some of the simpler code examples were a revelation and it was astonishing to find a fully functional regular expression processor in a dozen or so lines as presented by Brian Kernighan. This was indeed beautiful code, compact yet still readable. As someone else noted, the art is not just knowing when to stop adding code but also when to stop removing it.

It’s certainly no lightweight book at 560 plus pages and it takes real effort to read although the nature of it means you can dip in to any chapter at random, following whatever interests you.

If you want to take your mindset as a developer to the next level, this is a good book. It’s also an interesting insight into certain programming problems and their solutions. You may also want to buy a copy just to support Amnesty International.

I would suggest though that this is a book you should browse at the bookstore first to be sure it’s something you’d enjoy although I’m confident that for many developers, it will be.