Premature Quote Sourcing

“Premature Optimization is the Root of all Evil.” — Donald Knuth

That’s a famous phrase! You’ve probably seen that quoted a whole bunch of times. I’ve said it a whole bunch myself. I went down a rabbit hole recently when I started noticing constructions like “usually attributed to Donald Knuth” instead of crediting the professor directly. And, what? I mean, the man said it, right? He’s still alive, this isn’t some bon mot from centuries ago. So I started digging around, and found a whole bunch of places where it was instead attributed to C. A. R. Hoare! (Hoare, of course, is famous for many things but mostly for inventing the null pointer.) What’s the deal?

Digging into the interwebs further, that’s one of those quotes that’s taken on a life of it’s own, and just kinda floats around as a free radical. The kind of line that shows up on inspirational quote lists or tacked on the start of documents, but divorced from their context, like that time Abraham Lincoln said “The problem with internet quotes is that you cannot always depend on their accuracy.”

But, this seems very knowable! Again, we’re talking about literally living history. Digging even further, if people give a source it’s usually Knuth’s 1974 paper “Structured Programming with go to Statements.”

“Structured Programming with go to Statements” is one of those papers that gets referenced a lot but not a lot of people have read, which is too bad, because it’s a great piece of work. It’s shaped like an academic paper, but as “the kids say today”, it’s really an extended shitpost, taking the piss out of both the then-new approach of “Structured Programming”, specifically as discussed in Dijkstra’s “Go to Statement Considered Harmful”, as well as the traditionalist spaghetti-code enthusiasts. It’s several thousand words worth of “everyone needs to calm down and realize you can write good or bad code in any technique” and it’s glorious.

Knuth is fastidious about citations, sometimes to the point of parody, so it seems like we can just check that paper and see if he cites a source?

Fortunately for us, I have a copy! It’s the second entry in Knuth’s essay collection about Literate Programming, which is apparently the sort of thing I keep lying around.

In my copy, the magic phrase appears on page 28. There isn’t a citation anywhere near the line, and considering that chapter has 103 total references that take up 8 pages of endnotes, we can assume he didn’t think he was quoting anyone.

Looking at the line in context makes it clear that it’s an original line. I’ll quote the whole paragraph and the following, with apologies to Professor Knuth:

There is no doubt that the “grail” of efficiency leads to abuse. Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered. We should forget about small efficiencies, about 97% of the time. Premature optimization is the root of all evil.

Yet we should not pass up our opportunities in that critical 3%. Good programmers will not be lulled into complacency by such reasoning, they will be wise to look carefully at the critical code; but only after that code has been identified. It is often a mistake to make a priori judgments about what parts of a program are really critical, since the universal experience of programmers who have been using measurement tools has been that their intuitive guesses fail.

Clearly, it’s a zinger tossed off in the middle of his thought about putting effort in the right place. Seems obviously original to the paper in question. So, why the confused attributions? Seems simple.

With some more digging, it seems that Hoare liked to quote the line a lot, and at some point Knuth forgot it was his own lone and attributed it himself to Hoare. I can’t find a specific case of that on the web, so it may have been in a talk, but that seems to be the root cause of the tangled sourcing.

Thats kind of delightful; imagine having tossed off so many lines like that you don’t even remember which ones were yours!

This sort of feels like the kind of story where you can wrap it up by linking to Lie Bot saying “The end! No moral.”

Except. As a final thought, that warning takes a very different tone when shown in context. It seems like to gets trotted out a lot as an excuse to not do any optimization “right now”; an appeal to authority to follow the “make it work, then make it fast” approach. I’ve used it that way myself, I’m must admit, it’s always easy to argue that it’s still “premature”. But that’s not the meaning. Knuth is saying to focus your efforts, not to waste time with clever hacks that don’t do anything but make maintenance harder, to measure and really know where the problems are before you go fixing them.

Previous
Previous

Friday linkblog, video game music piano covers edition

Next
Next

What seems to be your boggle, citizen? 30 years of Demolition Man