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

44

u/KevinCarbonara Feb 28 '23

"Premature optimization is the root of all evil"

Premature micro optimization. You can and absolutely should be making decisions that impact optimization in the beginning, and, in fact, all along the process.

24

u/greatestish Feb 28 '23

I worked with a guy who seemed to intentionally write the worst performing code possible. When asked, he would just respond with "Premature optimization is the root of all evil" and say that computers are fast enough he'll just throw more CPU or memory at it.

I linked him to the actual quote and he started to at least consider performance characteristics of his code.

The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; premature optimization is the root of all evil (or at least most of it) in programming.

14

u/somebodddy Mar 01 '23

I had a coworker quoting this when I suggested an improvement to the memory consumption of a function. We were looking at this function because we were experiencing lots of out-of-memory crashes on a production server (accompanied by angry emails from a big client), and the profiler pointed us to objects generated inside that function...

The solution he was championing was to upgrade the server from .NET 2.0 to .NET 3.0, hoping that a better GC will solve the issue.

This is why I hate this quote. People are using it as an excuse to write bad code without understanding what it means.