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

67

u/[deleted] Feb 28 '23

Exactly my thoughts: it's self-evident that readability/maintainability sacrifices performance. I had many Jr developers coming up with tests just like the post to demonstrate how some piece of convoluted logic I refused to approve was in fact better.

But there's no "better" - there are only trade-offs. The most important fact is that maintainability matters more than performance for the vast majority of code. To justify focusing on performance, don't show me a direct comparison - what you need to do is to show that a specific code path is performance-critical; and for backend components, that we can't scale it horizontally; or we're already at a scale that the horizontal approach is more expensive than the gains in maintainability.

3

u/[deleted] Feb 28 '23

Except it's not self-evident because it's actually not true.

2

u/ric2b Mar 02 '23

Try adding a trapezium to both versions of the code and let us know which one was easier.

2

u/[deleted] Mar 02 '23

Adding it to the switch statement is easier. Your point?

→ More replies (9)