Steele: Yes. Exactly.
Seibel: Is there anything that you would like to talk about?
Steele: Well, we haven’t talked that much about the beauty in programs,and I wouldn’t want that to go without remark. I have read some programsthat really strike me as having a kind of beauty to them. TeX is oneexample, the source code for TeX. METAFONT a little less so and I don’tknow whether it’s just because I use the program less or there’s somethingsubtly different about the organization of the code or about the design ofthe program that I like less. I really can’t decide.
There are certain algorithms that strike me as just wonderful. I have seenlittle pieces of program that were marvels of code compression back in thedays when that mattered—when you had only a megabyte of memory,whether you used 40 words or 30 really mattered, and people would reallywork hard sometimes to squeeze a program down. Bill Gosper wrote theselittle four-line wonders that would do amazing things if you then connectedan amplifier to the low bits of some accumulator while it was twiddling thebits.
This may seem like a terrible waste of my effort, but one of the mostsatisfying moments in my career was when I realized that I had found a wayto shave one word off an 11-word program that Gosper had written. It wasat the expense of a very small amount of execution time, measured infractions of a machine cycle, but I actually found a way to shorten his codeby 1 word and it had only taken me 20 years to do it.
Seibel: So 20 years later you said, “Hey Bill, guess what?”
Steele: It wasn’t that I spent 20 years doing it, but suddenly after 20 years Icame back and looked at it again and suddenly had an insight I hadn’t hadbefore: I realized that by changing one of the op codes, it would also be afloating point constant close enough to what I wanted, so I could use theinstruction both as an instruction and as a floating point constant.
Seibel: That’s straight out of “The Story of Mel, a Real Programmer.”
Steele: Yeah, exactly. It was one of those things. And, no, I wouldn’t wantto do it in real life, but it was the only time I’d managed to reduce some ofGosper’s code. It felt like a real victory. And it was a beautiful piece of code.It was a recursive subroutine for computing sines and cosines.
So that’s the kind of thing we worried about back then. When Iprogrammed on the IBM 1130, there was this concept of a boot card, whichis a single card you put on the front of your deck. You hit a start button onthe computer and the hardware would automatically read the first card andput it in the first 80 locations in memory. And then start execution at agiven location. And the job of that card was then to be a real card-readerroutine to read the rest of the cards, and then that’s how you got yourselfbootstrapped.
What made it hard on the IBM 1130 was that cards have only 12 rows andit was a 16-bit computer word. So the 12 bits were scattered throughoutthe 16 bits of instructions, which meant that some instructions couldn’t berepresented on the card. Therefore any instructions that couldn’t berepresented on the card had to be built by using other instructions thatwere on the card. So you had this very complicated trade-off—“Whatinstructions can I use, and if I use this instruction; I’m going to need severalother instructions on the card just to build it”—and this presented atremendous amount of pressure and you only got 80 words to write yourroutine, and so you do tend to use things like reusing instructions as data,using a piece of data for more than one thing. If you can manage to put thislittle subroutine there in memory, then its address can also be used as a dataconstant. This is what it took—it was origami and haiku and all that as astyle of programming. And I spent several years doing that.
Seibel: Do you think that people who went through that discipline arebetter or worse programmers in the current environment?
Steele: They got experience at dealing with resource constraints and tryingto measure them accurately.
Seibel: Well, learning to measure them accurately is a good thing. But itcan also cut both ways where you develop habits of programming that arenow maladaptive.
Steele: It’s easy to become too fixated on optimizing something justbecause you can, even though it’s not what you need to work on. That’sindeed true. I’m glad that my son had the experience of programming TIcalculators when he was in high school. Because again, those hadmoderately severe memory constraints. And so he had to learn how torepresent data in compressed forms to get it to fit in the calculator. Iwouldn’t want him to spend his whole programming career that way, but Ithink it was a useful experience.
Seibel: Back to code beauty—that kind of haiku, origami programming isbeautiful for the reason that any intricate little thing is beautiful.
Steele: Yes. But I should emphasize that that piece of Gosper’s code isbeautiful not only because you can compress it in this way—one of thereasons it’s so small to begin with is because it’s based on a beautifulmathematical formula, a triple angle formula for the sine function. And thatrecursion can be expressed very concisely on this particular architecturebecause that architecture was designed to support recursion in a way thatother machines of its day weren’t. So there are several different aestheticsmelding together, combined in this one routine.
Seibel: You also mentioned Knuth’s TeX, which is obviously a much largerprogram. What is it that makes that program beautiful?
Steele: He took a very, very complicated program with lots of special casesand reduced it to a single, very simple paradigm: sticking boxes and gluetogether. That was an immensely critical breakthrough. It turns out to beflexible not only for typesetting text but for all manner of other things aswell that have to do with laying things out visually, two-dimensionally, on apage. I wish that more GUI interfaces were based on boxes and glue forlaying out buttons and things like that.
Seibel: So there is beauty to be appreciated once you understand whatboxes and glue means, you can say, “Yeah, that’s a deep and righteous ideaand I appreciate the beauty of that and see how it would apply outside thisone program.” Is there further aesthetic quality that you get—and can onlyget—by reading through the source code and seeing how that theme playsout? Or is it more that you read the whole thing and then at the end yousay, “Wow, that was really all based on this one simple, but not simplistic,idea.”?
Steele: It’s a combination of those. And Knuth is really good at telling astory about code. When you read your way through The Art of ComputerProgramming and you read your way through an algorithm, he’s explained itto you and showed you some applications and given you some exercises towork, and you feel like you’ve been led on a worthwhile journey. Andyou’ve seen interesting sights along the way. Wandering through the code ofTeX I feel much the same way. I’ve learned some things about programming.And some parts of them are mundane and perfunctory and so forth. Andother ones you say, “Wow, I didn’t think of organizing it that way.” It’s alittle of each.
Seibel: At the other end of the spectrum from code beauty, software isalso full of painful historical warts that we can’t get rid of, like differing lineendingconventions.
Steele: Yes. We spent hours and hours in the Common Lisp committeejust debating the treatment of end of line in order to accommodate bothUnix, which used just newline, and the PDP-10 systems, which used CRLF.And getting the definition of newline just right so it worked on both thoseoperating systems was a nightmare.