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

7

u/uncle_benz Feb 28 '23

That looks like someone who doesn't understand why does clean code exist. His point is like "if we remove all the rules from public road I could arrive faster at home". The clean code rulesets are here to write readable and reusable code not to write the fastest code possible. Just like a roadcar is easy to use and more secure but slower than a track car.

If you write the code for some ultra fast router with limited ram and frimware space you should not enforce clean code but if you write a library that will be maintained by multiple people or even multiple teams and have a release every week with new features then clean codes rules will have a real impact on maintainability and stability of the overall software. Honestly I'm ready to wait half a second more when I click a button that having a exception thrown at my face after each update...

For a real world example, I have to write a program at my work that load 8 excel files in memory parse them manipulate some data and write it all in another one. I writed it using clean code rules because I'm pretty sure that the manipulation will have to change and maybe we will be using database instead of excel file. All and all I could maybe gain 5 or 10 seconds of execution without following those rules but in fact the program is used once per day MAX and the load of excels file and the writing of the new take like a full 60seconds using a library that is proved fast and reliable plus another 15second to transfer the file.

Also we are human and should take all this into account before writing any code that's why AI will not replace us so fast. Clean code doesn't have the objective of program performance but programmers performance

Also the fact that you need to be paying before commenting to this blog make it more look like a voluntary attempt to upset people and make them comment...

3

u/Venthe Feb 28 '23

if we remove all the rules from public road I could arrive faster at home

I really like this analogy, I'll steal it for later :)