A synthesized report on the provenance, authorship, circumstances, and intended meaning of the aphorism, with an enumeration of the misattributions and errors surrounding it. Compiled July 16, 2026.
Where: Donald E. Knuth, “Structured Programming with go to Statements,” ACM Computing Surveys 6(4), December 1974, pp. 261–301, at p. 268 (the “Efficiency” section) — the full canonical form; and simultaneously, in weaker form, in Knuth’s ACM Turing Award lecture “Computer Programming as an Art,” Communications of the ACM 17(12), December 1974, at p. 671.[1],[2]
Who: Donald E. Knuth. The competing attribution to C. A. R. Hoare originates with Knuth himself, who in 1989 misremembered his own sentence as “Hoare’s dictum.”[3] Hoare disclaimed authorship in writing in 2004;[4] Knuth confirmed authorship in writing in 2012.[5] No pre-1974 occurrence by anyone has ever been produced.
Why: Written at the height of the structured-programming (“goto”) controversy ignited by Dijkstra’s 1968 letter, as part of Knuth’s attempt to defend measured, targeted optimization of critical inner loops against a rising conventional wisdom that all concern for small efficiencies was sinful.[1],[6],[7]
Meaning: A two-sided engineering rule, not an anti-performance slogan: ignore small efficiencies in the ~97% of code that doesn’t matter, because doing so purchases the right — and the duty — to optimize the measured-critical ~3% aggressively, after profiling has identified it.[1]
The sentence in its famous full form appears exactly once in the primary literature, on page 268 of Knuth’s December 1974 survey article, in a section titled “Efficiency”:
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, say 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%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified. — D. E. Knuth, “Structured Programming with go to Statements,” Computing Surveys 6(4), Dec. 1974, p. 268.[1]
No attribution to any other person accompanies the sentence; Knuth writes it in his own voice, as a maxim of his own.[1],[8]
A weaker sibling appears in the same month in Knuth’s Turing Award lecture, delivered at the ACM Annual Conference in late 1974 and printed in the December 1974 Communications of the ACM:
The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming. — D. E. Knuth, “Computer Programming as an Art,” CACM 17(12), Dec. 1974, p. 671.[2]
The lecture explicitly cross-references the survey paper (“I have discussed its proper role in my paper on structured programming, which appears in the current issue of Computing Surveys”), so the two texts are contemporaneous and mutually aware.[9] Shreevatsa R. plausibly conjectures the hedged lecture form preceded the polished article form — quotes tending to improve between talk and paper — but publication is simultaneous and the point cannot be settled from the record.[8] The survey article was reprinted in Knuth’s collection Literate Programming (1992), which further circulated the passage.
Donald Ervin Knuth (b. 1938), then Professor of Computer Science at Stanford University, author of The Art of Computer Programming and 1974 Turing Award laureate. The evidential chain for sole authorship is unusually complete for a programming aphorism:
But I also knew, and forgot, Hoare’s dictum that premature optimization is the root of all evil in programming.[3] He supplies no citation, and none has ever been found. This single uncited sentence is the source of the entire Hoare-attribution tradition — a short-circuit in which Knuth forgot not only the maxim but that he himself had coined it.[8]
I’m sorry I have no recollection how this quotation came about. I might have attributed it to Edsger Dijkstra. I think it would be fair for you assume it is common culture or folklore.[4] Hoare thus declines authorship and can only conjecture Dijkstra — the person to whom such pronouncements were culturally natural.
I did say things like ‘Premature optimization is the root of all evil in programming’— listing it alongside his verified “Beware of bugs in the above code” quip, in a note explicitly concerned with separating true and false Knuth quotations.[5]
No document places the phrase in Hoare’s or Dijkstra’s mouth before December 1974, and both alternative attributions trace to exactly one uncited sentence (Knuth 1989) and one hedged conjecture (Hoare 2004) respectively. The scholarly conclusion is that the phrase is Knuth’s.[8],[10]
An interpretive note on the mechanism of the 1989 slip. Hoare is a pervasive presence in the very paper that coins the maxim: Knuth cites him admiringly on subscript range-checking (the “sailor and life preserver” argument), on for-loop design permitting compilers to avoid range checks, on axiomatization of the proposed iteration syntax, and — pivotally — for the remark, encountered in the fall of 1973, that a language should ideally let an optimizing compiler describe its optimizations in the source language, which Knuth says lifted a veil from his eyes.[1] Hoare was also co-author of the 1972 Structured Programming volume that frames the whole paper.[21] When Knuth reached for a name fifteen years later, Hoare was the colleague most densely associated in his memory with this cluster of efficiency-and-discipline ideas — a plausible mechanism for the misattribution, though this explanation is interpretive rather than documented and should be presented as such.
The sentence was forged in the hottest years of the structured programming controversy — the decade-long argument over the go to statement and, more broadly, over what disciplined programming should mean. A chronology of the people and events leading to December 1974:
| Date | Event |
|---|---|
| c. 62 AD | The rhetorical template: 1 Timothy 6:10 (KJV: For the love of money is the root of all evil). By the 19th century the pattern “X is the root of all evil” was a standard parodic mold (e.g., “the lack of money is the root of all evil,” attested 1872).[11] Knuth — a lifelong Lutheran church organist — wrote squarely inside this template; the borrowing is stylistic. |
| 1959–1965 | Early goto skepticism: Heinz Zemanek voices doubts (1959); D. V. Schorre at UCLA programs without gotos from 1960; Peter Naur publishes the first remarks on harmful gotos (c. 1963); George Forsythe purges gotos from CACM algorithms (1964); Dijkstra reports that programmer quality is inversely proportional to the density of goto statements(1965); Peter Landin frames goto-avoidance as producing more transparent programs (1965). All recorded in Knuth’s own “Historical Background” section.[1] |
| 1966 | Böhm and Jacopini prove that sequencing, selection, and iteration suffice in principle — the theorem later (over-)cited as structured programming’s theoretical cornerstone.[1] |
| Mar 1968 | Dijkstra’s letter in CACM 11(3), pp. 147–148. He submitted an article titled “A Case against the GO TO Statement”; to speed publication, editor Niklaus Wirth converted it to a letter and invented a new title of his own: “Go To Statement Considered Harmful.”[1],[12],[13] The letter makes waves; Dijkstra later tells Knuth he received a torrent of abusive letters.[1] |
| late 1960s | The “software crisis” (named at the 1968 NATO conference) fuels a reform movement; in Knuth’s telling, people begin to renounce every feature of programming that can be considered guilty by virtue of its association with difficulties— not only gotos but pointers, globals, even assignment.[1] |
| 1969–1971 | Knuth is personally hit by the tide while teaching introductory programming (1969), repeatedly consulting Bob Floyd; their joint paper exhibits programs that resist goto-elimination without extra computation.[1] |
| Summer 1970 → 1971 | Knuth and about a dozen Stanford students and industry representatives conduct an empirical profiling study of real FORTRAN programs, published as “An Empirical Study of FORTRAN Programs” (Software—Practice and Experience 1(2), 1971, pp. 105–133). Its principal conclusion is the importance of the program profile: execution time concentrates in a very small fraction of the code, and profile-keeping should be standard practice.[14] This is the empirical substrate of the later “97% / critical 3%” figures: the 1974 paper states that most of the running time in non-IO-bound programs is concentrated in about 3% of the source text,citing this study and Dan Ingalls’s profiling tools.[1] |
| Oct 1972 | William A. Wulf, “A Case Against the GOTO,” 25th ACM National Conference — the classic statement of the anti-efficiency conventional wisdom Knuth would push against: More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason — including blind stupidity.[6] |
| 1972–1973 | Structured programming reaches peak fervor, codified in the book O.-J. Dahl, E. W. Dijkstra, and C. A. R. Hoare, Structured Programming (Academic Press, 1972)[21] — the proximate provocation for Knuth’s paper, whose opening sentence reads: It is impossible to read the recent book Structured programming without having it change your life.[1] Also: Dijkstra’s Turing lecture “The Humble Programmer” (1972); an entire ACM National Conference session (1972); five Datamation articles (Dec 1973). Dijkstra privately tells Knuth: Please don’t fall into the trap of believing that I am terribly dogmatical about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it.[1] |
| Feb 1974 | Knuth lectures on the material at UCLA, deliberately arguing both sides; nearly everybody in the audience had the illusion that I was largely supporting his or her views, regardless of what those views were![1] |
| Dec 1974 | Publication of both texts containing the aphorism. The survey paper’s stated aim: a reasonably well balanced viewpoint about the proper role of go to statements— with a title chosen primarily to generate attention(a deliberate provocation against the “Considered Harmful” orthodoxy).[1],[7] |
The famous sentence does not arise in an argument against optimization; it arises in an argument for it. Knuth has just shown a hand-optimization (loop doubling, Example 2 → 2a) that saves about 12%, and confronts the emerging orthodoxy head-on:
The conventional wisdom shared by many of today’s software engineers calls for ignoring efficiency in the small; but I believe this is simply an overreaction to the abuses they see being practiced by pennywise-and-pound-foolish programmers… In established engineering disciplines a 12% improvement, easily obtained, is never considered marginal; and I believe the same viewpoint should prevail in software engineering. — Knuth 1974, p. 268 (immediately preceding the famous sentence).[1]
The “root of all evil” sentence is the concession that balances this defense — the acknowledgment that the grail of efficiency leads to abuse
— before Knuth pivots back to the critical 3%. Structurally, the aphorism is one half of a dialectic, and its purpose in the paper is to license disciplined optimization, not to forbid it.[1],[15]
The famous figures are layered — a rhetorical estimate resting on an empirical claim resting on a measurement study — and the layers should not be conflated:
Experience has shown (see [46], [51]) that most of the running time in non-IO-bound programs is concentrated in about 3% of the source text,followed by the observation that
we often see a short inner loop whose speed governs the overall program speed to a remarkable degree.[1] The two citations are Dan Ingalls’s work on execution-time profiling [46] and Knuth’s own 1971 empirical study [51].
profile-keeping should become a standard practice in all computer systems, for casual users as well as system programmers.[14] The sentence most often quoted from the dynamic arm — that less than 4 per cent of a program generally accounts for more than half of its running time — is the direct ancestor of the 1974 “about 3%”; note, however, that the present report has verified that sentence only through secondary reproductions of the paper, and it should be confirmed against the primary text (Section 3 of the SP&E article) before quotation.[14]
after working with such tools for seven years, I’ve become convinced that all compilers written from now on should be designed to provide all programmers with feedback indicating what parts of their programs are costing the most— dating his own profiling practice to roughly 1967 and grounding the operational meaning of “premature”: prior to measurement.[1]
In short: the 3% is a rounded generalization of a measured hot-spot concentration result from 1970–71; the 97% is merely its arithmetic complement; and neither was ever offered as a precise constant.
Read in situ, the maxim encodes four claims:
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.Optimization becomes legitimate after the critical code has been identified — hence his call, radical for 1974, that all compilers should provide profiling feedback to programmers by default.[1]
Yet we should not pass up our opportunities in that critical 3%.A 12% gain in a hot inner loop, easily obtained, is never marginal by ordinary engineering standards.[1]
In the Turing lecture, the same idea serves a slightly different argument: that efficiency work has a legitimate aesthetic place in programming-as-art, provided it is done at the right times and places.[2],[9] Fifteen years later, in “The Errors of TeX,” Knuth invoked the maxim confessionally — as a rule he himself knew, and forgot
while building TeX — which is precisely the passage in which the misattribution to Hoare was born.[3]
I have no recollection how this quotation came about… I think it would be fair for you assume it is common culture or folklore.[4]
I might have attributed it to Edsger Dijkstra) plus Bruce Eckel’s unsourced credit spawned a third attribution tradition. No Dijkstra text contains the phrase. The irony was noted by Gerwitz: the sentence’s actual first use occurs in a paper written partly as a rejoinder to Dijkstra’s goto position.[4]
it’s an urban legend that it’s an urban legend that it was originally Knuth,with the (incorrect) embellishment that Hoare had been quoting Knuth. There is no evidence Hoare ever used the phrase at all; the only documented chain is Knuth → Knuth-crediting-Hoare → everyone else.[10]