On Premature Optimization
Mar. 12th, 2021 01:16 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
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, 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 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.
no subject
Date: 2021-03-12 08:30 pm (UTC)Also, this notion is very much inspired by my assessment of my own "imbalances" - I tend toward air and get lost in the clouds, gravitate toward water and its connection with meaning, but am frequently befuddled by fire (hang back, am unsure of my desires, and flow downhill or disperse completely) which makes it hard for my meaning-making to be manifested through earth.
But perhaps my comment reflects my very imbalance (I struggle with "I want optimal, but optimal what?" and then turn to look at the big picture from air's height) and so this algorithm might mimic that.
no subject
Date: 2021-03-12 09:30 pm (UTC)Chuang Tzu said this one best, I think: Be an ugly tree when you need to be an ugly tree. Be a wildcat when you need to be a wildcat. Be a yak when you need to be a yak. Good advice, but a difficult lesson to apply in the moment...