I’ve been carting around Beautiful Code (amazon link) for quite a number of months – getting in a little reading on plane flights, the periodic long commute, and sometimes a little evening reading. I can’t say I “finished” it – the book isn’t one that is easily absorbed from front to back, but I think I’m ready to put it into the bookshelf for a while instead of keeping it in the handy-to-grab-and-read stack on the table.
For anyone who hasn’t picked it up, the book is a collection of essays about what various authors have perceived as “beautiful code”. That’s its strength and its weakness. It’s certainly quite the collection of people using the same language to describe (at times) radically different opinions. But then using a word like “beautiful” is just asking for a subjective opinion – and that’s what you get. While I (obviously) don’t agree with all the opinions in the essays, it’s a really nice collection for someone interested in finer points of software engineering – and be prepared to get a breath from a huge range of languages.
One of my favorites from the book is the essay “Treating Code as an Essay” byÂ æ¾æœ¬è¡Œå¼˜ (Yukihiro Matsumoto – author of Ruby). Although I still can’t claim to have learned Ruby, I’ve gone out of my way to hear him talk and read what he has to say. I find his philosophy on language design fascinating, and was once lucky enough to hear him speak about what inspired him to create Ruby. (I bought a copy of Babel-17 based on that talk… good science fiction)
Another was “Beautiful Concurrency” by Simon Peyton Jones. It should not be surprising to anyone who’s heard of Simon that the example bits for that were all in Haskell – another language I’ve not wrapped my brain about.Â
An third interesting essay was Byran Cantrill‘s “A Spoonful of Sewage” – which was actually more of debugging war story narrative and “what not to do” essay rather than an essay on an example of what made some piece of code writing beautiful. Bryan’s a damn smart guy – so smart that he can be really tricky to follow at times. If you’re interested in hearing an example of what I mean, check out his DTrace Review (video). His particular essay, which I enjoyed reading, was sort of my downfall with this book. It was a difficult essay to slug through, deep with the issues of threading and locking in an operating system, and I found it difficult to really parse out the points. Even after reading it several times, I’m not sure I understand what some of that was all about anyway.
There were more articles I just didn’t get at all, and after lightly tasting them, I put them back down and skipped over to other sections. Maybe if I’d bulled through, I would have found something illuminating. I guess I was disappointed in that there were more than a few of those kinds of essays where I just really didn’t want to “work for it” to get the point. Especially when it was unclear there was a point – at least related to the concept of “beautiful code”.Â
So I guess I wouldn’t go out of my way to recommend this book in a general sense, but there are some interesting essays and examples buried within. Â I think at the core, I was expecting more examples and descriptions of why someone thought that a specific piece of code was beautiful. I got some of that, but not as much as I’d hoped for. I’m not going to pitch this sucker into the “sell back to used books” bin – it’s going in the shelf. In the end, I think I’ll call it a “tricky” book and leave it at that.
Â
For whatever it’s worth, I did actually write that chapter with beauty in mind: both the timeless beauty of correct software and the hideous ugliness of flawed software. But yes, it’s a dense chapter — apologies for that, and certainly my apologies if it turned you off the book. If it’s of any consolation, if I had to write five chapters for Beautiful Code, the other four would have been easier on the brain — I deliberately picked one of the nastiest problems that I had ever worked on, in part so I could record it for posterity. So it’s not you, at any rate — it’s a tough issue. (Though that said, I thought Simon’s piece was also a pretty steep climb — so I don’t think that I was alone in my desire to challenge the reader…)
LikeLike
Thanks for the ping Bryan! I’ll give the book a few weeks on the shelf and then take a stab at your essay again. Maybe with a little time, I’ll be ready to charge into the book again.
LikeLike