Mark’s Bookshelf: The Practice of Programming

Today, the hash function has selected The Practice of Programming by Brian Kernighan and Rob Pike. On my shelf you’ll probably find a couple dozen reference books that are written about various programming languages. This book is one of a smaller handful that literally talks about programming: how to write clear, general, reliable programs that are portable, perform well, and are an actual pleasure to read. I’ve great respect for Kernighan and Pike: their older book The Unix Programming Environment was one of my principle references on Unix when I was still a fledgling acolyte into the ways of Unix. More than just being informational, that book was inspirational. It showed that the Unix environment gave the programmers power to implement powerful new things using powerful mechanisms and simple techniques. It conveyed the appropriate mindset to make maximal use of the operating system facilities.

The Practice of Programming fufills a similar role, but instead of focusing on operating facilities, it focuses on programming languages. It must be confessed that while it does have brief forays into C++ and Java, it’s a book that includes mostly C code. For this, and its concentration on “programming in the small” rather than larger, group based development techniques, it has been labelled as “dated” or “old-fashioned”. I think this is like criticizing a guy who can cut a beautiful dovetail joint by hand for not using glue and nails. To Kernighan and Pike, good programs are actually pleasurable to read, and the vast majority of code doesn’t pass the test, and the larger the program and the greater the number of programmers, the less likely it seems to pass this simple test of aesthetics. Nevertheless, I would submit that there are lessons here for every programmer. The good thing is that each point of style is illustrated with actual code designed to convey the lesson. Thus, you learn what good code looks like via the Socratic Method: by asking questions about code, and stimulating thought and critical thinking about code in all its aspects: from design to implementation to testing and debugging.

If you don’t know C, you might need another book to get off the ground, but The Practice of Programming is a book with lasting value on my shelf.

Addendum: Rob Pike has his own (and in some circumstances) controversial view about what beautiful programs look like. You can see some hint of them in his work on the Go language at Google. One of the explicit design goals for Go was to make programming more fun and more expressive. I think it’s a fascinating new language and points out a bit how programming has been led astray in recent years. If you want a taste of what Go is like, check out his Google Talk:


httpv://www.youtube.com/watch?v=rKnDgT73v8s