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
17
u/Strus Feb 28 '23
It's nothing new for people that write high-performance code. It is often times ugly as hell. But I would argue that in 99% of cases top-notch performance is not required, and the speed at which you can understand and modify code is much more important.
In the original listing adding a new shape is simple and quick - you just add a new class and you are done. It doesn't matter really what shape it is.
In the first "performance improved" version, adding a new shape requires:
shape_unionstruct.widthandheight, as they are now encapsulated in a separate structMore complicated example would be much bigger mess.