Premature Optimization Is the Root of All Evil

"Premature optimization is the root of all evil (or at least most of it) in programming" --Donald Knuth

"Craft is attention to details" --Zach Lieberman

Donna Haraway, "Informatics of Domination"

I recently drafted a short text for a friend responding to Donna Haraway's "Informatics of Domination" chart, specifically the pair of terms "Perfection -- Optimization." My assignment was to reflect on these terms, including how Haraway has aligned them to specific historic periods, while also suggesting a third term to add to the pair. (I'll save talking about the third for when the text comes out.)

Perfection and optimization are terms that originate in moral and metaphysical discourse. Perfection refers to something having been fully accomplished, to something in a state of completion. From a Latin root verb meaning "to make," perfection entails a process of production. To perfect something is to intervene positively in its development, to push it in a particular direction, to craft it and finish it and make it shine. Perfection connotes maturity, development, completion.

Similarly, optimization refers to the most favorable state. The word is derived from a root meaning "best." Yet optimization is more sober and pragmatic than perfection. Universals matter less here; identities are not determined in absolute terms, but rather provisionally, nominally. The "best" is not eternal, or essential, and certainly not given by God, even if kings and elites try to claim divine authority. Rather, the optimal is simply one arrangement among others. The optimal is the most efficient organization, the most pleasing assemblage, or the most suitable configuration.

Optimization creates an "aristocracy" in the literal sense. Each thing is configured in such a way as to exploit the best arrangements of its various affordances. Indeed Aristotle -- that great thinker of the aristos -- paid particular attention not to the pure idea of things but to their particular natures, whatever characterized them best. Optimizers are, in this sense, materialists at heart. They care little for what something is in its transcendental essence, but rather for how something transpires in the here and now.

As Haraway's periodization suggests, the priests and patriarchs of high modernity eventually lost ground to the engineers and curators of postmodernity. During optimization the goal is not so much to achieve purity of essence, but to fall into the crest of an existing process, exploiting the most energy from the best vantage. This is one reason why Gilles Deleuze was so enamored with surfing, among all sports. Or why, in music, the break won the spotlight over the boring old structures of verse and chorus.

The morality of perfection is more traditional than optimization, in that perfection means looking "upward"  toward the universal or the general, while optimization means "downward" toward this or that situated instance. Completion is divine, while optimization remains mundane -- as illustrated well in expressions like "the best of all possible worlds." (The best, okay...but the best within worlds...within the set of possible worlds.)

With all this in mind, how should one understand computer scientist Donald Knuth's pronouncement that "premature optimization is the root of all evil"? And does this contradict Zach Lieberman's quote also given at the top?

Knuth's quotation encapsulates the divided soul of computation. In one sense programmers are eminently pragmatic and committed to a finitist view of the world. Yet in another sense they remain unreconstructed Platonists.

Focus on the word "premature." Few programmers would claim that optimization alone is the root of all evil, quite the opposite. So much of what coders do is about following the pathway of optimal efficiency (which is all the more true the closer one gets to hardware). I'm thinking of min/max algorithms, or offloading calculations to the GPU, or server load balancing, or slimming data to reduce latency, or any number of other examples. Warning against "premature optimization" means something like "don't make a general thing particular until you have to." Don't shift toward Aristotelianism if you can remain a Platonist for a while longer. It's a strange, if not also revealing, philosophy. (Whether it means computer science is fundamentally conservative is a question we will leave for another day.) In other words I take Knuth to mean that optimization -- valuing efficiency over all else -- is less important than the "art" of programming.

At the same time someone like Zach Lieberman, a virtuosic coder if there ever was one, can say flatly and correctly that "craft is attention to details." The optimal is also the particular. Someone who optimizes is someone who particularizes around details. Something is the "best" but the best for a particular context. So if Knuth leans in favor of the general, Lieberman sides instead with the particular.  No surprise -- I'm with Zach in the end.