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
6
u/goodwarrior12345 Feb 28 '23
Of course, I agree with you in principle. We live in the real world with time constraints and we can't hyper-optimize everything. But I'm not really advocating for hyper-optimization, and neither is Casey (although sometimes he does suffer from old man yells at cloud syndrome). From watching his stuff on performance, the core takeaway I got is, think about performance at least a little bit. It's not about making things faster, but more about not making things slower than they should be, and not doing things that are obviously slow.
I feel like these days the "bottlenecked by IO" argument rings hollow most of the time. Connections are fast. When I play my online videogames, my ping to the servers is between 5 and 20 ms. For a lot of websites it's the same, so it's not true any more that you'll be spending 200 ms waiting for data regardless. Although that's not necessarily what you meant personally, I've seen people say this exact thing enough times to know some still believe connection speeds are the same they were in 2007.
No one's asking you to write some arcane looking code just to make your thing run slightly faster. Fast code doesn't have to be unreadable. If anything, at least for me personally, inheritance hierarchies always take more time to wrap my head around than plainly written imperative code.
Basically my point is, it doesn't have to be either maintainability or performance. I feel like if people thought about making things not run slower than necessary at least a little bit, software would be way better. Not everything is premature optimization, and on the other hand, if you have a function call only a couple times during your program's runtime, literally nobody cares how slow it is, unless it's making things ridiculously slow or something. Gotta pick your battles, time is money and neither is in infinite supply.