Writing Efficient Code
If the best approach is not to optimize, how can we avoid any need to improve code performance? The answer is to design for performance, planning to provide adequate quality of service from the outset, rather than trying to whittle it out at the last minute.
Some argue that this is a dangerous road to follow. Indeed, there are potential hazards for the unwary. If you try to optimize as you go along, then you’ll write at a lower level than needed; you’ll end up with nasty, hacky code full of low-level performance enhancements and back-door interfaces.
How do we reconcile these seemingly opposing views? It isn’t hard, because they’re not actually at odds. There are two complementary strategies:
Write efficient code.
Optimize code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access