4 ms·
Premature optimization used to mean unnecessarily writing assembly or borderline obfuscated C in the name of performance, which led to programs being difficult
by kintamanimatt 13y ago
Premature optimization used to mean unnecessarily writing assembly or borderline obfuscated C in the name of performance, which led to programs being difficult to comprehend, hence it being the root of all evil. Today this has been perverted to mean "hey, buddy, if you think about performance you're optimizing prematurely!"
People need to learn their history before throwing out such maxims.
- Nursie 13y agoPerhaps misguided optimisation would be a better term, and seems to be what Knuth is driving at. People do spend a lot of time worrying about all the wrong things, many of which a decent optimising compiler will take care of. Efficient code should always be on your mind, but actual optimisation probably ought to be done with the aid of a profiler rather than a hunch a 'clever' way of doing something.
- rahoulb 13y agoAgreed - I've seen cases where someone obsesses about shaving milliseconds off a tight loop whilst using a profiler would reveal that the real bottleneck is the code called just before entering the loop. Premature optimisation is optimisation without knowing what needs to be optimised.
- fulafel 13y agoYou live a sheltered life! In games and other development cultures where performance is a traditionally staple argument, C++ cowboys say things things like "We can't have an scripting API method that returns a list of component names since it will be slow and it will malloc" Since the same guys are doing the crunch phase optimizations, their prejudices have a survival bias which carries a lot of apparent "battle hardened" weight
- fauigerzigerk 13y agoIn my mind a "sheltered life" is something completely different. It's when you can get away with using 20 servers instead of 2, based solely on unproven and unrealistic productivity claims about dynamic languages and certain frameworks.
- jokoon 13y agoIt always baffled me to hear that quote, and then notice the examples in the art of programming are all done in ASM. We live in a an age where computers are so fast it's considered acceptable to be an engineer and just blurb out code and show people that "shit just works". That quote is indeed very misleading, because at the time, CPU were still getting faster frequencies, so optimizing problems were solving themselves. Today we face a problem where the faster algorithms are the one we need, because multithreading is hard, and also because there is no real tech to do clustering out of the box. I'll always smirk when I look at this quote, and look at spidermonkey, v8, chrome, and carmack's