Stephen Ramsay    Home

The Beautiful Thing

I’ve been teaching English and History majors how to program for several years now. During that time, I think I’ve figured out how to present this material in a way that countenances its complexity and power while still being accessible to people without technical backgrounds. The result is a course that I’m really very proud of, and that I expect to teach, in some form, for the rest of my career.

Every time I start the process of teaching people how to write software, there’s always something on the tip of my tongue. Programming has its elementary katas — “Hello, world!”, this is a variable — and it’s fun to gradually build up complicated programs from these first steps over the course of a semester. But I’m always seized with the desire to start teaching programming at a far more fundamental level. The thing I want to say to my students, right at the start, is something like this:

“Down at the very bottom of a computer is something so simple, so elemental, so primitive, that it almost makes you want to laugh. The most complicated software systems ever written are built upon a chain of abstractions that starts with this very simple mechanism. Computation is one of the most elegant ideas in the history of the world, because a child can grok a nand-gate. Everyone should see this for the same reason that everyone should see the moon through a telescope. It’s just a beautiful thing.”

Of course, we just can’t go there. The “beautiful thing” would get us into circuit logic. And once that was explained, the students would naturally want to know how this somehow gets us all the way to Facebook and Tetris. And that would require explanation of sequential logic, the design of an alu, the fundamentals of computer architecture, machine language, assemblers, vms, compilers… The beautiful thing ends up being the entire curriculum of computer science.

Except that even people who have been through that curriculum can fail to see the beautiful thing, even after taking courses in most of those areas. I was programming for years before I saw the beautiful thing.

The Elements of Computing Systems: Building a Modern Computer from First Principles by Noam Nisan and Shimon Schocken is the only book I’ve ever read that explains the beautiful thing all the way from top to bottom. And it does it in about 350 pages.

Nisan and Schocken aren’t content to give you a rolling narrative about the chain of abstractions upon which modern computing rests. They want you to build a computer yourself, starting with primitive gates and going all the way up to application programming. On the book’s website, there are a series of simulators (strongly reminiscent of the simulators used by actual engineers) that you can download and use to create the entire platform. The first exercise for the reader asks you to use the hardware simulator and its own Hardware Description Language (hdl) to create the logic gates for not, or, and, nand, xor, the multiplexor… There’s very little hand waving going on here. The hdl is not Verilog, but it’s not a toy language either. You’re building a real computer. In later chapters, you implement an assembler, write an os, create a programming language, and build applications. Really.

My list of the greatest books ever written on programming — the enduring classics of computer science — is just like everyone else’s, and it’s a short list. Structure and Interpretation of Computer Programs by Abelson and Sussman. The Art of Computer Programming by Knuth. Friedman’s The Little Lisper (and subsequent volumes). The C Programming Language by Kernighan and Ritchie. This book is on that list. It’s a genuine modern masterpiece.

Every year, I have students who, at the end of the semester, say something like, “I had no idea how fascinating computers are.” I now plan to hand them this book and say, “It gets even better.”

[update: I should mention that the book does assume you know how to program, though literally any language will do. The book would be fully accessible to anyone who has taken a programming course of any kind, or managed to learn any of the major languages on their own. I don’t think beginners would find it an easy read, but it’s not a unduly hard one either. It’s on my short list in part because of its lucid, graceful explanations of difficult matters.]

blog comments powered by Disqus