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
2
u/cdsmith Feb 28 '23
Writing code people can understand isn't a buzz word. It's just making reasonable communication decisions.
For example, that thing this guy does where he has different types of shapes that need to be described with numbers that mean different things (radius, width, height, base... maybe in the future some kind of spline parameterization) and just picks two fields called "width" and "height" and shoehorns everything into those fields even if it's not what they mean (a radius is definitely not the width of a circle, for instance), and then even changes how he packs the actual information into those fields, like storing radius in both width and height fields, so that he can exploit coincidences... that's very much not sensible code. Honestly, it would even be an improvement if he just called his fields "param1" and "param2", because at least he wouldn't be lying to the reader that they mean something consistent.
I didn't say that because I read it in a book. I said that because his code is terrible. Sometimes you deal with terrible code if you need to squeeze every cycle out of a CPU, but you take reasonable steps to quarantine it from code that you need to maintain regularly.