“Premature Optimization”
You might have come across the famous software optimisation quote popularised by Donald Knuth:
Premature optimization is the root of all evil.
– Sir Tony Hoare
It has been commonly interpreted as “don’t think about performance in the beginning,
you can fix any performance problem later”. This interpretation is completely and categorically wrong.
Original Quote
It’s very common for statements to lose their original meaning when context has
been stripped and that’s exactly what happened here.
We should forget about small efficiencies, say about 97% of the time:
premature optimization is the root of all evil.– Sir Tony Hoare
The short version is missing a crucial part: “small efficiencies”.
At the time the quote was made, “small efficiencies” referred to techniques
like minimising the number of instructions used.
With the additional context, the quote takes on a significantly
different meaning: it’s making a statement only about micro-optimisations
(“small efficiencies“), not about performance in general.
Hoare was simply advising against micro-optimisations without finding
the hotspots first: the “premature” part refers to lacking measurements.
Hotspot Optimisation: “Make it Fast Later” Fallacy
It’s quite tempting to adopt a “ship now, make it fast later” approach.
While optimisations will improve performance, it won’t change the
fundamental performance envelope. As tech stack fundamentals, access patterns,
data dependencies and data structures are baked into a design,
it’s not possible to hotspot your way out o