The Origin of “Premature Optimization Is the Root of All Evil”

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.

Summary of findings

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]

a) Where the quote originated

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.

b) Who originated it

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:

  1. 1974 — the coinage. Both December 1974 texts present the sentence without attribution.[1],[2]
  2. 1989 — the self-misattribution. In “The Errors of TeX,” Knuth writes: 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]
  3. 2004 — the disclaimer. Queried by Hans Gerwitz in January 2004, Hoare replied: 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.
  4. 2012 — the confirmation. In a handwritten note to Mark Harrison (prompted by an unrelated Stack Overflow sourcing dispute), Knuth wrote: 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.

c) The circumstances that precipitated it

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:

DateEvent
c. 62 ADThe 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–1965Early 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]
1966Bö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 1968Dijkstra’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 1960sThe “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–1971Knuth 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 → 1971Knuth 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 1972William 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–1973Structured 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 1974Knuth 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 1974Publication 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 immediate textual context

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 penny­wise-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 provenance of the 97% / 3% split

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:

  1. The rhetorical layer (1974). “Say about 97%” is marked as an estimate by Knuth’s own hedge (“say about”); its complement, the 3%, is the load-bearing figure. The empirical claim in the paper is: 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].
  2. The empirical layer (1970–71). The cited study was a three-month project in the summer of 1970, conducted by Knuth with about a dozen students and software-industry representatives, published as “An Empirical Study of FORTRAN Programs.”[14] It had two arms: a static analysis of a corpus of FORTRAN programs chosen “at random” from a wide variety of people and applications (statement-type frequencies, relevant to compilation speed), and a dynamic arm in which about 25 of the programs were selected at random and profiled — instrumented with frequency counts recording how often each statement actually executed in a run — with the “inner loops” of 17 programs examined in further detail.[14],[20] The paper’s stated principal conclusion is the importance of the program profile and the recommendation that 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]
  3. The tooling layer. Reference [46] is D. Ingalls, “The Execution Time Profile as a Programming Tool,” from the 2nd Courant Computer Science Symposium on compiler optimization (held 1971; proceedings Prentice-Hall, 1972).[20] Daniel H. H. Ingalls Jr. was then a Stanford graduate student in Knuth’s orbit building FORTRAN profiling tools — the same Dan Ingalls who shortly afterward became the principal implementor of Smalltalk at Xerox PARC. Knuth’s 1974 call for profiling-by-default cites this tooling work directly.[1]
  4. The personal layer. Knuth adds in 1974 that 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.

d) What Knuth was trying to convey

Read in situ, the maxim encodes four claims:

  1. Misallocated effort is the disease. Programmers spend enormous time worrying about the speed of noncritical code, and those local “optimizations” carry real costs in debuggability and maintainability.[1]
  2. “Premature” means “before measurement.” Knuth immediately warns that 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]
  3. The critical 3% is a duty, not an indulgence. 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]
  4. “Optimization” meant micro-optimization. In the 1974 context — assembly-level instruction counting, loop doubling, register husbandry on machines where every cycle was precious — “small efficiencies” denoted low-level tuning, not architectural performance design. Commentators note the quote is now routinely stretched far beyond that referent.[15],[16]

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]

Conflicts, exaggerations, miscommunications, and mistakes — enumerated

  1. Knuth’s self-misattribution (1989). The claim that the maxim is “Hoare’s dictum” originates with Knuth in “The Errors of TeX” and carries no citation. It is a memory error by the coiner himself, fifteen years on.[3],[8]
  2. The derivative Hoare attribution. Books, talks, and articles crediting Hoare (a large fraction of all citations of the quote) descend from item 1. No independent Hoare source exists, and Hoare disclaimed it: 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]
  3. The tertiary Dijkstra attribution. Hoare’s 2004 conjecture (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]
  4. Folklore about the folklore. The debunking itself has been garbled in circulation — e.g., the Hacker News formulation that 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]
  5. Wrong-venue citations. The quote is frequently sourced to The Art of Computer Programming and to “the 1960s” (e.g., Stackify’s widely-read article does both). It appears in neither TAOCP nor the 1960s; both 1974 venues are journal publications.[17] Others cite “Knuth’s book Structured Programming with go to Statements” — it is a paper, not a book.[18]
  6. Misquotation by truncation. Dropping “We should forget about small efficiencies, say about 97% of the time” and “Yet we should not pass up our opportunities in that critical 3%” inverts Knuth’s meaning, converting a pro-measurement, pro-hot-loop-optimization argument into a blanket anti-performance thought-terminating cliché. This is the single most consequential distortion in the quote’s reception, extensively documented.[15],[16],[19]
  7. Numerical over-literalism. The 97%/3% figures are rhetorical estimates (“say about 97%”) informed by, but not identical to, the 1971 profiling study’s findings on hot-spot concentration (dynamic analysis of ~25 programs; inner loops of 17 examined; commonly quoted as “less than 4 per cent” of a program accounting for over half its running time). They are sometimes cited as measured constants; they are not — the 3% is a rounded generalization and the 97% its arithmetic complement. See “The provenance of the 97% / 3% split” above.[1],[14],[20]
  8. Name and detail errors in the secondary record. Peter Seibel’s Practical Common Lisp — the book that mainstreamed the Hoare email — misspells the correspondent as “Hans Genwitz of phobia.com” (correctly: Hans Gerwitz).[8]
  9. An editor-invented title upstream. A relevant miscommunication in the precipitating chain: the goto controversy’s totemic artifact, “Go To Statement Considered Harmful” (1968), bore a title Dijkstra never wrote — editor Niklaus Wirth retitled the submission (“A Case against the GO TO Statement”) and recast it as a letter to speed publication, as Dijkstra recorded in EWD1308. The inflammatory framing that Knuth’s 1974 title parodies was thus itself an editorial artifact.[12],[13]
  10. Form drift in Knuth’s own recollections. Knuth’s 1989 and 2012 renderings both use the Turing-lecture form (“…root of all evil in programming”), not the Computing Surveys form — evidence that Knuth remembered the family of sayings rather than a canonical sentence, and a caution for anyone quoting “the” original.[3],[5]

Sources

  1. Knuth, D. E. “Structured Programming with go to Statements.” ACM Computing Surveys 6, no. 4 (December 1974): 261–301. doi:10.1145/356635.356640. Quote at p. 268. Full-text transcription: kohala.com/start/papers.others/knuth.dec74.html; PDF widely mirrored (e.g., pic.plover.com/knuth-GOTO.pdf). Reprinted in Knuth, Literate Programming (CSLI, 1992).
  2. Knuth, D. E. “Computer Programming as an Art.” 1974 ACM Turing Award Lecture. Communications of the ACM 17, no. 12 (December 1974): 667–673. doi:10.1145/361604.361612. Quote at p. 671.
  3. Knuth, D. E. “The Errors of TeX.” Software—Practice and Experience 19, no. 7 (July 1989): 607–685. doi:10.1002/spe.4380190702. “Hoare’s dictum” passage reprinted in Literate Programming (1992), p. 276.
  4. Gerwitz, H. “Premature optimization is the root of all evil.” Blog post, August 12, 2004, reproducing Hoare’s email of January 2004. hans.gerwitz.com; 2004 version archived at the Wayback Machine (phobia.com, Aug. 31, 2004 capture).
  5. Harrison, M. “A note from Donald Knuth about The Art of Computer Programming.” EastBay CodeHaus blog, March 6, 2012, with scans of Knuth’s handwritten reply. codehaus.blogspot.com; mirrored at markharrison.net/stackoverflow/knuth/.
  6. Wulf, W. A. “A Case Against the GOTO.” Proceedings of the 25th ACM National Conference (1972): 791–797; reprinted in Yourdon, ed., Classics in Software Engineering (1979). ACM DL.
  7. Yourdon, E., editorial introduction to Knuth’s paper in Classics in Software Engineering (Yourdon Press, 1979). ACM DL. See also Rosenberg, S., “Code Reads #5: Knuth’s ‘Structured Programming with go to Statements’,” Wordyard, Nov. 17, 2006.
  8. Shreevatsa R. “Premature optimization is the root of all evil.” The Lumber Room (blog), May 16, 2008 (updated 2010). shreevatsa.wordpress.com. The central forensic survey; also documents the Practical Common Lisp footnote (Seibel, Apress 2005, ch. 32 n. 4) and its “Genwitz” misspelling.
  9. Effectiviology. “Premature Optimization: Why It’s the ‘Root of All Evil’ and How to Avoid It.” effectiviology.com (quotes the Turing lecture’s cross-reference to the Computing Surveys paper).
  10. Hacker News discussion, item 24136340 (Aug. 2020) — illustrative of the layered folklore (“urban legend that it’s an urban legend”). news.ycombinator.com.
  11. Wikiquote, “C. A. R. Hoare,” sourcing note on the quote and on the 19th-century “lack of money” parody (Bowker, 1872); mirrored at quotepark.com. The biblical template is 1 Timothy 6:10 (KJV).
  12. Dijkstra, E. W. “What led to ‘Notes on Structured Programming’.” EWD1308 (2001), E. W. Dijkstra Archive, University of Texas at Austin — Dijkstra’s own account of Wirth’s retitling. Summarized in Apt, K. R., “The Man Who Carried Computer Science on His Shoulders,” Inference 6, no. 1 (2021).
  13. Dijkstra, E. W. “Letters to the Editor: Go To Statement Considered Harmful.” Communications of the ACM 11, no. 3 (March 1968): 147–148. doi:10.1145/362929.362947. Original title: “A Case against the GO TO Statement” (EWD215).
  14. Knuth, D. E. “An Empirical Study of FORTRAN Programs.” Software—Practice and Experience 1, no. 2 (1971): 105–133. doi:10.1002/spe.4380010203. Also issued as Stanford CS Report CS-186 / AI Memo AIM-137.
  15. “Revisiting Knuth’s ‘Premature Optimization’ Paper.” Probably Dance (blog), June 19, 2025. probablydance.com — close reading of the quote’s context and its habitual misuse.
  16. Stanchev, M. “Premature Optimization: Universally Misunderstood.” milen.me. milen.me — on “small efficiencies” as period micro-optimization; documents Alexander Keller’s query tracing the Hoare credit.
  17. Stackify. “Why Premature Optimization Is the Root of All Evil.” stackify.com — cited here as a documented instance of the wrong-venue/wrong-decade error (attributing the quote to TAOCP, “published… in the 1960s”).
  18. Taro Codes. “Premature Optimization is the Root of All Evil” (2023). taro.codes — instance of the “book” mislabeling; useful on 1974 hardware context.
  19. Barczak, J. “Stop Misquoting Donald Knuth!” The Burning Basis Vector (blog), 2015. joshbarczak.com — on the truncation-driven inversion of Knuth’s meaning.
  20. Ingalls, D. “The Execution Time Profile as a Programming Tool.” In Compiler Optimization (Proceedings of the 2nd Courant Computer Science Symposium, 1971), edited by Randall Rustin. Englewood Cliffs, NJ: Prentice-Hall, 1972. Cited as reference [46] of Knuth 1974; bibliographic details verified via the reference list of J. Cohen, Software—Practice and Experience 7 (1977), doi:10.1002/spe.4380070403.
  21. Dahl, O.-J., E. W. Dijkstra, and C. A. R. Hoare. Structured Programming. A.P.I.C. Studies in Data Processing No. 8. London and New York: Academic Press, 1972. Contains Dijkstra, “Notes on Structured Programming”; Hoare, “Notes on Data Structuring”; Dahl and Hoare, “Hierarchical Program Structures.” Cited as [17; 55] in Knuth 1974’s opening sentence.