5 ms·
We've all heard this, but it's important to practice it: Premature optimization is the root of all evil.
by YCode 10y ago
We've all heard this, but it's important to practice it:
Premature optimization is the root of all evil.
- tropo 10y agoToo often the word "premature" is forgotten, and too often "optimization" is understood to be "any care about performance whatsoever, either low-level or high-level". The comment comes from a time when people would regularly do foul things like changing code similar to a switch/case into something that involves shoving an integer directly into a flags register or worse. (then you must add another case or port to different hardware... uh oh!) Failure to think about performance from the beginning can get you in deep trouble. The worst case is when there is no bottleneck to be found by a profiler; instead there is slowness spread all throughout. This may force a total rewrite or abandonment of the project. Language choice is particularly prone to causing this, but habitual poor choices can mess you up just as badly.