Hacker News new | ask | show | jobs
by unpythonic 2332 days ago
> 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%.

Knuth, "Structured Programming with Goto Statements". Computing Surveys 6:4 (December 1974), pp. 261–301, §1. doi:10.1145/356635.356640

No one has said to ignore optimization, what the quote is actually telling us is to avoid falling into the trap of micro-optimizations which don't really affect the overall performance of the system. Yes, you can spend a week making the world's fastest substring-in-string function, but if you're only checking that your email address has an @ in it, that's kinda silly.

Make your programs fast by concentrating on the areas which give you the most bang for the buck and avoid falling into rat holes where you optimize something which has no impact on the system overall.

1 comments

> No one has said to ignore optimization

Well, maybe nobody is _saying_ that (Knuth definitely wasn’t) but, as the author points out, this is how a lot of applications of the “premature optimization is the root of all evil” rule end up: any discussion of optimization if forbidden as premature until it’s too late to fix the problems and then it’s “good enough” because we “have to get to market”.

If that's a problem, don't "discuss" it. Just Do!