5 ms·
I think whenever the topic of premature optimization comes up most people forget the whole Knuth/Hoare quote: > We should forget about small efficiencies, say
by ehnus 16y ago
I think whenever the topic of premature optimization comes up most people forget the whole Knuth/Hoare quote:
> We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
Everyone seems to latch on the second part, but the first part, and the context, are very important. At the time the quote was first coined they were considering "premature optimization" to be the use of "inc eax" instead of "add eax, 1". The key, I think, is the bit about small efficiencies -- we shouldn't worry that "inc eax" uses two bytes less than "add eax, 1" from the outset, but cache thrashing should definitely be a concern.
Optimization is something that should always be in a programmers mind, especially when programming embedded machines. If you're not at a point where you are optimizing the code you are working with then you should be writing it in a way that it can be optimized down the road.
I would think that anyone who uses "premature optimization is the root of all evil" as a retort is fair game for being challenged on how they would actually optimize their code when they have the chance :)
(disclaimer: I write code for video games, my world view may not be the same as yours, though I still believe this applies globally.)