Charles Petzold



Beautiful “Beautiful Code”

July 11, 2007
Roscoe, N.Y.

If Microsoft Press had published Beautiful Code they might have put a rachet set on the cover. I myself happen to consider ratchet sets to be very beautiful, but I think the folks at O'Reilly had a better cover idea:

(Actually, it was Christopher Seiwald who suggested "a flock of geese flying in a V formation" for the cover. My sicko cover idea was a variation of Michelangelo's "Creation of Adam" but replacing Adam with a pasty guy with taped glasses, and God with Alan Turing.)

The premise behind Beautiful Code is simple: Each of the 33 chapters describes something the authors consider "beautiful code." The chapters are described on the Amazon page for the book:

and you can even order the book from that page as well. The book is out, it's gorgeous, and it's an instant programming classic.

Beautiful Code was conceived by University of Toronto professor Greg Wilson and meticulously edited by O'Reilly editor Andy Oram, and I am honored to have been a part of the project.

For my contribution, I first discussed some code I had heard about but never seen: The implementation of the BitBlt function in Windows 1.0. The function managed to support 256 different raster operations by generating machine code on the stack and then executing it. I then updated that concept to the era of managed code: I show how to code digital image filters in a C# WinForms program by generating Intermediate Language customized for the bitmap size and the particular filter being applied, and then executing it.

By buying this book, you're also helping to do some good in the world, for as the back cover says, "All author royalties will be donated to Amnesty International."