3 ms·
While the points are correct, they are bad advice, except for the last point: prefer O(1) over O(n) because all (premature) optimizations are evil! What works i
by z3t4 9y ago
While the points are correct, they are bad advice, except for the last point: prefer O(1) over O(n) because all (premature) optimizations are evil! What works in one engine for example (Firefox) might not work in Chrome, or the next version of the same engine. So write stupid simple naive code until you actually need to optimize. Then go for algorithms first, changing something from O(n) to O(1) will have a bigger impact then for example creating static binaries (which most of the time will be slower because there will be no run-time optimizations)
- lou1306 9y agoI don't find it "premature" optimization at all. IMHO it is barely "optimization" if you're just using the right tool for the job (namely a hash table instead of a list when you need key-value lookup).
- bryanrasmussen 9y agoThe original premature optimization quote was specifically about spending a lot of time optimizing complicated algorithms in an environment in which computation was often business required if used so as a consequence one could count on people staying around more than insignificant amounts of time to get a response. In the environments most of this would be used on people do not stick around long periods of time, therefore any simple optimization that one can do in the preliminary development of an application is not premature. But this article sucks, as do most articles with a list of coding tips for a particular language/platform.