4 ms·
I've been "premature optimization is the root of all evil"ed in more code reviews than I can count - yet when people complain about software, they first complai
by commandlinefan 9y ago
I've been "premature optimization is the root of all evil"ed in more code reviews than I can count - yet when people complain about software, they first complain that it's ugly and then they complain that it's slow. Users don't care what it's written in.
- sitkack 9y agoThere is fast (optimization) and slow (the most straightforward thing with no consideration to perf) and then not-slow. I think not-slow is a happy medium. Fast code should and probably is, totally unreadable, looking like AlphaGo optimized your program.
- smitherfield 9y ago>Fast code should and probably is, totally unreadable, looking like AlphaGo optimized your program. Yes and no; multithreading and optimizing to remove branches can do a number on readability, but I find optimizing for cache locality and compile-time evaluation often makes code more readable. It depends on the language obviously.
- commandlinefan 9y agoIn theory I think you're correct - you _can_ go crazy overoptimizing code to the point where it's completely unreadable. However, in my experience, it takes a lot of effort to get to this point, especially in modern languages. It seems to me that most developers err in the other direction: whatever works as long as it took the least amount of time to program (although this might well be partly driven by the management "agile" obsession with accounting for how every 15-minute increment of time was spent).
- snowwrestler 9y agoIf your users are complaining that your software is slow, then optimization would not be premature. Optimization is premature when the cost of creating or managing it outweighs the business benefits it provides.