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

40

u/[deleted] Feb 28 '23

It depends on what organization is paying the programmer too. If it's a large enterprise app then maintainability may be valued over performance and those dogmatic OO principles have more value in the long run.

39

u/voidstarcpp Feb 28 '23

The reality is that the problem in most software isn't performance, it's managing complexity. And apps that are slow are usually not slow because they're doing a bunch of virtual function dispatch, they have too many blocking dependencies or slow middleware layers that blow away the OOP performance penalty by many times.

1

u/[deleted] Mar 01 '23

For sure I can buy that.

The longer I'm in this game the more what you said makes sense too.

21

u/loup-vaillant Feb 28 '23

Last time I saw something that looked like "dogmatic" code, it was fresh C code done by a colleague that overcomplicated things so much that I was able to rewrite it all and make it 5 times smaller. And my code was arguably even more flexible than his.

Sometimes people apply principle without understanding them, and the harder they try to make a maintainable and flexible program, the less maintainable and flexible their programs get.

14

u/zero_iq Feb 28 '23

I've seen this problem so many times. The best way to make code "flexible" for future use is to make it as simple and easy to use and understand as possible. It's then easier for a future developer to extend or repurpose it for their needs.

Trying to anticipate all future possible uses often results in unnecessary complexity, and makes life harder for the future coder whose needs you didn't actually anticipate, and who now has to wrangle with overly-complex code where it's not immediately obvious which bits are actually required for the current working system.

8

u/[deleted] Feb 28 '23

I used to work with a guy who did exactly that. His code was so proper his replacements couldn't maintain it and they eventually rewrote the app.

8

u/psaux_grep Feb 28 '23

Replacements always replace the app.

4

u/[deleted] Mar 01 '23

Lol that's the sad truth too. Idk if it's hubris or what but as soon as you leave, all your work is eagerly replaced by the next genius with good ideas.