What is Premature Optimization?

Discussion in 'Java' started by tenxian, Apr 30, 2008.

  1. tenxian

    tenxian Guest

    Is it good or bad?
    tenxian, Apr 30, 2008
    #1
    1. Advertising

  2. "tenxian" <> wrote in message
    news:...
    > Is it good or bad?


    Not good...the keyword being "premature", meaning "untimely, too soon,
    hasty" in this context.

    Premature optimization often refers to steps taken to improve speed or
    reduce memory consumption, *before* there is reason to believe that such
    steps are necessary. It does _not_ refer to judicious choice of fast and/or
    memory-consumption-reducing architecture, design, algorithms and data
    structures at the earliest possible stage.

    AHS
    Arved Sandstrom, Apr 30, 2008
    #2
    1. Advertising

  3. tenxian

    Roedy Green Guest

    On Tue, 29 Apr 2008 22:00:32 -0700 (PDT), tenxian
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is it good or bad?


    Stop jerking us around and ask real questions. Get yourself a project
    and write some code.
    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Apr 30, 2008
    #3
  4. tenxian wrote:
    > Is it good or bad?


    (Typically it's considered bad form to put the main question as the
    subject.)

    Anyways, "premature optimization" (most likely deriving from the old
    quote, "Premature optimization is the root of all evil," attributed to
    Donald Knuth, author of TAOCP) is a simple phrase that is not idiomatic,
    and thus can be parsed directly.

    Premature - something happening before it should
    Optimization - the process (or at least an attempt) of increasing
    efficiency (with general connotation to time and somewhat so less so to
    space)

    Therefore, "premature optimization" is the process whereby the
    efficiency is increased before it should be, or, cleaning up a bit,
    "optimizing" code before one can say whether or not it should be. It
    generally refers to people optimizing code based on where he or she
    believes the code to be underperforming, instead of based on rigorous
    tests which pinpoint the exact blocks which are consuming the most time.

    As to your latter question, it is generally considered poor form.
    Knuth's quote I've cited above, but another programmer (his name escapes
    me at the moment) said something to the effect that "more sins are
    committed in the name of optimization than any other cause--including
    stupidity." I suspect it is up to decide to yourself, though...

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
    Joshua Cranmer, Apr 30, 2008
    #4
  5. tenxian wrote:
    > Is it good or bad?


    OK, now I'm sure you're a troll. Begone!
    Mike Schilling, May 1, 2008
    #5
  6. tenxian

    thufir Guest

    On Wed, 30 Apr 2008 06:14:37 +0000, Arved Sandstrom wrote:


    > Not good...the keyword being "premature", meaning "untimely, too soon,
    > hasty" in this context.
    >
    > Premature optimization often refers to steps taken to improve speed or
    > reduce memory consumption, *before* there is reason to believe that such
    > steps are necessary. It does _not_ refer to judicious choice of fast
    > and/or memory-consumption-reducing architecture, design, algorithms and
    > data structures at the earliest possible stage.


    Donald Knuth said, paraphrasing Hoare[1],

    * "We should forget about small efficiencies, say about 97% of the
    time: premature optimization is the root of all evil." (Knuth, Donald.
    Structured Programming with go to Statements, ACM Journal Computing
    Surveys, Vol 6, No. 4, Dec. 1974. p.268.)

    http://en.wikipedia.org/wiki/Optimization_(computer_science)

    Actually, he's talking about *small* efficiencies. Just thought I'd post
    the quote!


    -Thufir
    thufir, May 1, 2008
    #6
  7. thufir wrote:
    > Donald Knuth said, paraphrasing Hoare[1],
    >
    > * "We should forget about small efficiencies, say about 97% of the
    > time: premature optimization is the root of all evil." (Knuth, Donald.
    > Structured Programming with go to Statements, ACM Journal Computing
    > Surveys, Vol 6, No. 4, Dec. 1974. p.268.)
    >
    > http://en.wikipedia.org/wiki/Optimization_(computer_science)
    >
    > Actually, he's talking about *small* efficiencies. Just thought I'd post
    > the quote!


    That is what it is all about.

    Programmers taking 4 nice reachable lines of code that work
    and replace them with 40 unreadable lines with 3 bugs to achieve
    a 5% speed increase of that code which because that code only
    takes 0.1% of total time result in a total performance improvement
    of 0.0005% and cost the company tens of thousands of dollars to
    find and fix the bugs !

    Arne
    Arne Vajhøj, May 1, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nomadx
    Replies:
    1
    Views:
    477
    dinser
    Sep 19, 2003
  2. Wayne Deleersnyder

    Premature end of script headers

    Wayne Deleersnyder, Nov 21, 2003, in forum: Perl
    Replies:
    1
    Views:
    650
    Wayne Deleersnyder
    Nov 21, 2003
  3. Ravikiran

    Zero Optimization and Sign Optimization???

    Ravikiran, Nov 17, 2008, in forum: C Programming
    Replies:
    22
    Views:
    838
    Thad Smith
    Nov 24, 2008
  4. jimxoch
    Replies:
    40
    Views:
    1,148
    Pascal J. Bourguignon
    Oct 5, 2009
  5. Replies:
    7
    Views:
    120
Loading...

Share This Page