Alessandro Lacava

on Designing and Developing Software. In love with Functional Programming.

Why You Shouldn’t Be Concerned About Optimization

When you were at the university or in any programming course, you–like me–were probably thought of the importance of optimization. In the real world though, you should strive for writing good code–possibly using bullet-proof Design Patterns–and defer optimization until later. Actually, you should optimize your code only if, after testing, you realize that optimization is strongly necessary. There are three aphorisms concerning optimization that you cannot but know:

  1. More computing sins are committed in the name of efficiency (without necessarily achieving it) than for any other single reason, including blind stupidity.
    William A. Wulf

  2. We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.
    Donald E. Knuth

  3. We follow two rules in the matter of optimization: Rule 1 Don’t do it. Rule 2 (for experts only). Don’t do it yet, that is, not until you have a perfectly clear and unoptimized solution.
    M. A. Jackson

Notice that these great computer scientists wrote these aphorisms when computers were much slower than today’s!