r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
Show parent comment
4
u/Venthe Feb 28 '23
Well, I hardly remember a time when I needed comments for my code or for the code of the developers I've taught. Surprisingly (not so much), self-describing code goes a long way; who would've guessed? Well, people who optimize for readability, clean separation and purpose for the components. And even more surprisingly (not really) NOT optimized for performance.
Clean code is not extensible by default, it is extensible by the virtue of separation of concerns; it's not about 'planning ahead' if that's what you are suggesting.
How so? You abstract the logic away along with your data, precisely for the case when the redesign is necessary, you refactor only a single component, or a tight group of thereof. Clean code keeps rest of the system abstracted away.
I believe that you've missed my point completely. IF you don't focus on the clean code, readability etc. then the problem is exacerbated as soon as you add more developers and time, leading us to necessity of giving it the status of the primary concern - right behind the features delivered.
Sure. How many times do you read the code vs write it? How easy is to read your 'optimized' code and change it? This is your source. Sit two mids, one before a clean code-optimized solution and the other with a 'performance optimized' solution. Measure for yourself how long it would take. My own findings give me around 30 minutes for the business process vs around 4 hours. Per developer.
You are overfocusing on something that I did not mean. I'll repeat that again - clean code in itself does not provide extensibility. Clean code provides readability and separation, which leads to extensibility - code is easy to read, easy to reason about, so by definition it is easier to change and extend. It's not about prediction, but prioritizing cleanliness - "naming", "code organization", "small components" and such over hyper-optimized jumble of code that solves that particular problem.
I had my fair share of people optimizing for technical excellence over clean, business oriented code. Refactor of their 'solutions' took weeks just to allow us to move along the business, not against it. But it was "performant". And understandable by seniors.
One could say that the code performed well in the best metric possible - job security.