Premature optimization is the root of all evil
When writing or optimizing code
What Does “Premature optimization is the root of all evil” Mean?
Optimizing for performance before understanding actual bottlenecks wastes time and creates complexity. Make it work first, measure, then optimize only proven problems.
Origin and History
The line is from computer scientist Donald Knuth's 1974 paper 'Structured Programming with go to Statements'. The full sentence is more nuanced: 'We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.' He went on to say programmers should not pass up opportunities in the critical 3%.
What Happens When You Break It
Premature optimization wastes time, creates unnecessary complexity, often optimizes wrong things, makes code harder to maintain, and provides negligible benefit.
Benefits of Following This Rule
Optimizing actual measured bottlenecks provides real gains, maintains code simplicity, focuses effort effectively, and improves what actually matters.