sdi: Oil painting of the Heliconian Muse whispering inspiration to Hesiod. (Default)
sdi ([personal profile] sdi) wrote2021-03-12 01:16 pm
Entry tags:

On Premature Optimization

In the study of algorithms, one is always, always concerned with efficiency: is this algorithm the best possible? But, of course, the question is: "best at what?" And what we find over and over again is that it is impossible to be the best at everything.

Usually, one cares about how fast your algorithm is, or how short your algorithm is, or how easy to change your algorithm is, or how didactic your algorithm is. But, often, improvement at any of these comes at a cost to all of the others! So one must be very clear on what it is they care about, and why they pursue it.

Yesterday, [personal profile] temporaryreality made an offhand comment about pursuing a balanced life, which was a surprising goal to me: would not one rather pursue being optimal at something? But then I realize that, often, one who is designing an algorithm is not yet sure how it will be used, and it is extremely wasteful to try to make your program fast if it is only rarely run, or didactic if nobody is ever going to look at it. We call this kind of thing premature optimization. It's considered good to start by making your algorithm a jack-of-all-trades unless you're sure exactly how it's going to be used.

And so [personal profile] temporaryreality is quite right that pursuing balance is a valuable goal. Indeed, I think it should be the default goal, for most people, most of the time.