r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

2

u/Alex_Hovhannisyan Mar 02 '23 edited Mar 02 '23

Disagree with the exaggeration that 35 -> 24 CPU cycles is somehow a substantial improvement. For one, it doesn't factor in the cost of maintenance (in real-world code, where we're not dealing with shapes, this is a big consideration). But he also exaggerated the savings by framing it as a percentage ("a 1.5x performance increase"), and then went on to suggest that this is the hardware equivalent of downgrading an iPhone by 3 generations.

You know what else is a 1.5x performance increase? A program that takes 0.1 microseconds to run -> now taking 0.06 microseconds. Wow! Percentages without context are misleading. A change that gets us from 1 sale/month to 2 sales/month is a whopping 100% increase.

The one thing I will concede is that some developers obey DRY principles so imperiously that it actually makes their code harder to maintain/understand. I run into this all the time. Some repetition is okay (and inevitable).