Byon October 8, 2010 12:15 PM
I recently finished Beautiful Code from O’Reilly Media. The Beautiful series of books each contain a series of chapters from experts in their fields, in this case, software developers from all over the industry. The contributors are given guidelines, of a sort. Some focus on programs, others focus on algorithms, still other focus on techniques.
There was, for me, at least some information to glean from each chapter, though there were some, like the Gaussian Elimination chapter, that felt less useful to me. However, by and large, the thirty three chapters are excellent reads. Now, I read through the book, one chapter after another, but there really isn’t any need to do that. You’re going to be just as well off opening the book to a chapter and reading through.
Charles Petzold, best known as the guy who wrote the books on Win32 API Programming, has an excellent piece on dynamic code generation in .NET, and how spending a small amount of time up front to build a complex algorithm with some customizations for a specific run case (such as loop unrolling, dropping no-ops, etc) can save an enormous amount of processing time. The fact that he did it in .NET was pretty cool, since this is a technique that most people simply never consider anymore, but it’s something I’ve been thinking about lately for a project that I’m planning.
While those were my favorites, in part because they felt relevant to projects I’m considering, the rest of the chapters are pretty excellent. The discussion of concurrency using Haskell’s Software Transactional Memory is a fascinating approach to safe concurrency. It works exceptionally well in Haskell, due to the fact that the language makes side-effects so implicit that it’s easy to prevent STM and side-effects from getting nested irresponsibly.
Then there are several chapters on code quality and formatting, mostly focusing on trying to make code read more like natural language. Which makes a lot of sense for long-term maintainability, which was really run home by the chapter from a Perforce developer on their DiffMerge algorithm, and how strong code standards have helped it evolve over ten years or so. Or from Ruby’s Matz about keeping code succinct and ‘bookish’, which is greatly aided in his mind by using a language like Ruby, of course.
Beautiful Code is a heavy book, there were a few chapters where the code was very Fortran or LISP heavy, both languages I know well enough to read, but with the Fortran in particular, my eyes glazed over a bit. Even the chapters written in languages I’m intimately familiar with, and that I was interested in the subject, occasionally would go down paths that were far more interesting to the author of that chapter than to me, but that happens in Essay.
I can say one thing for sure: You’re not going to love this entire book. But you will find several chapters to love, and I doubt there will be many you can’t at least appreciate. I’m not entirely sure that I feel the book is worth it’s $50.00 cover price, but then, I’m a little cheap. I got it under their eBook deal of the day, and I know it was worth well more than the $10 I did spend on it. Overall, it’s a really good read, with some excellent essays, but I would definitely suggest treating this book like what it is, a compilation of disparate pieces, and not a cohesive whole.