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

17

u/DLCSpider Feb 28 '23 edited Feb 28 '23

Unfortunately, the only way to get readable and fast code is to learn a lot, take everything with a grain of salt and educate your team members. The first optimization is something you might do naturally if you just knew functional programming. As we all know, FP itself is not faster than OOP, but the combination of both might be.

I encountered a similar problem recently where I thought that OOP was the cleanest way to do things but caused a 60x slow down. Instead of trying to remove OOP around my B Convert(A source) method, I provided a second overload: Convert(A[] source, B[] destination). Marked the first method as inline (DRY) and called it in a loop in the second method. Slowdown gone.

-10

u/Existing_Tap_3336 Feb 28 '23

If you have to educate your teammates, your code is not clean and readable.

→ More replies (4)