Rules Of Optimization

The "rules" of optimising are a rhetorical device intended to dissuade novice programmers from cluttering up their programs with vain attempts at writing optimal code. They are:

  1. FirstRuleOfOptimization - Don't.
  2. SecondRuleOfOptimization - Don't... yet.
  3. ProfileBeforeOptimizing

It is uncertain at present, whether cute devices such as this have, or ever will, change any attitudes.

It changed mine.

Mine, too.


MichaelJackson used to say (when asked about optimization):
  1. Don't.
  2. Don't Yet (for experts only).

This is republished in JonBentley's ProgrammingPearls.

And lets not forget these famous quotes:

"The best is the enemy of the good."
-- MrVoltaire

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

"We should forget about small efficiencies, say about 97% of the time: PrematureOptimization is the root of all evil."
-- DonKnuth (who attributed the observation to CarHoare)

See: OptimizeLater, LazyOptimization, OptimizationUnitTest, OptimizationStories,, UniformlySlowCode, CodeDepreciation, RulesOfOptimizationClub


View edit of May 6, 2009 or FindPage with title or text search