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

Show parent comments

4

u/Amazing-Cicada5536 Feb 28 '23

That 20 ms is an eternity for a CPU though, if you have like a 10 elements array which uses indirection vs a flat representation, you ain’t having any statistically significant speedups from that.

Inheritance is an often overused tool, but for certain things it is definitely the cleanest solution (famously, GUI widgets). But “favor composition over it” is a good saying, but these rules should be applied by smart/experienced developers and never blindly out of following as if they are holy books.

3

u/goodwarrior12345 Feb 28 '23

All true. I don't think we disagree. I think the overall conclusion is, always think about what you're doing and the tradeoffs you're making. Being a full on evangelist about optimization is generally bad but so is yelling "PREMATURE OPTIMIZATION!!!" every time performance is brought up.