← Back to context

Comment by JKCalhoun

2 days ago

Personally, I see a kind of arc in programming style over time. It does begin naive, and more-experienced you will look back at your early code realizing you were essentially re-inventing the wheel in one place or you may see now that a look-up table would have been more efficient (as examples).

As you learn more techniques and more data structures the "cleverness" creeps into your code. To the degree that the cleverness might have a complexity cost, sometimes the cost may be worth it—perhaps not always though.

Naive-you would have struggled to understand some of the shortcuts and optimizations you are leveraging.

But then still more-experienced you revisits the more clever code with years now to have both written and attempted to debug such code. You may now begin to eschew the "clever" to the degree its cleverness makes the code harder to understand or debug. You might swear off recursive code for example—breaking it into two functions where the outer one runs a loop of some sort that is easier to set a break-point in and unwind a problem you were seeing. Or you might now lean more on services provided by the platform you are programing for so you don't have to have your own image cache, your own thread manager, etc.

I feel like in that last stage, most-experienced you may well be writing code that naive-you could have understood and learned from.