[Proj] Re: Premature optimization [was NAD problems on OSX 10.5Leopard]

Ed McNierney ed at topozone.com
Fri Jan 18 17:14:12 EST 2008


Daan –

 

Curmudgeons?  On THIS list?  I’m shocked – shocked, I say!

-          Ed

 

From: proj-bounces at lists.maptools.org [mailto:proj-bounces at lists.maptools.org] On Behalf Of strebe at aol.com
Sent: Friday, January 18, 2008 4:28 PM
To: proj at lists.maptools.org
Subject: [Proj] Re: Premature optimization [was NAD problems on OSX 10.5Leopard]

 


Not to be a curmudgeon, Ed (and Norman), but that isn't what the quote means, and that is exactly what I meant by "Often misunderstood to mean, 'Engineering for scalability is the root of all evil.'" The original quote, in its full glory, is "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." It is the "small efficiencies" disclaimer that is important.

Let us say your program is required (amongst many other operations) to sort a lot of numbers. You know from the beginning that "a lot" isn't just some fixed 12 values; it's arbitrarily large. But, in order to avoid "premature optimization", you throw in a simple bubble sort and proceed with the remainder of your programming.

Well. You haven't avoided premature optimization.  You've written the wrong program. It won't scale. Bubble sort's execution time increases exponentially as the number of items to sort increase. It's inappropriate for any but the tiniest counts of numbers. You should have used quicksort instead. C.A.R. Hoare knew this and had it in mind — he did, after all, invent quicksort.

Yet I constantly run into colleagues who excuse their program's performance failures running under stress as, "Oh, I wanted to get it working; now we can optimize it." Well. Optimizing means tuning your algorithm. It doesn't mean replacing your algorithm. If you replace it, you're writing a new program. You have completely lost the benefit of concentrating on the algorithm instead of the performance details.

The correct interpretation is, "Choose the correct algorithm; tune it later if you need to."

Regards,
-- daan Strebe

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/proj/attachments/20080118/3e467e4d/attachment.html


More information about the Proj mailing list