premature optimization

expression

programming

Tuning code for speed before you know it matters, at the cost of clarity and time.

Knuth's line - 'premature optimization is the root of all evil' - warns against contorting code for performance gains that profiling has not shown you need. The full quote allows for the critical few percent that do matter; the point is to measure first, then optimize the part that actually moves the needle.

Also known as: root of all evil, premature optimization is the root of all evil

Sources

  • Knuth, 'Structured Programming with go to Statements' (1974), quoting Hoare

All glossary entries