Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Golfing and Sprinting

by Abigail-II (Bishop)
on Mar 16, 2004 at 00:59 UTC ( [id://336899]=note: print w/replies, xml ) Need Help??


in reply to Golfing and Sprinting

On the other hand, Knuth, among others, claim that "premature optimization is the root of all evil", for a few reasons:
  • You can easily waste more time and money optimizing code than you will save in running it
  • Optimized code often has a funky, fragile structure that is hard to modify or generalize down the line.
  • Optimized code is often hard to read, and/or things are done in inexplicible ways.
Yes, good points, although I'd change the 'often' of the second and third points to 'sometimes' - assuming we talk about Perl here, and not C or assembler. Note however that these points all deal with full programs, probably running in production, and created while being paid.
Because of these problems, we should not encourage novices by indulging in such 'evil' speed optimization challenges.
That's a conclusion I don't want to draw. Typically the challenges presented here and in other forums are about a small piece of code, that's isolated from their context. I think that playing around with a small piece of code, trying out alternatives, consider what they do, without the burden of context is an excellent way to understand a language better.

Abigail

Replies are listed 'Best First'.
Re: Re: Golfing and Sprinting
by lachoy (Parson) on Mar 16, 2004 at 03:35 UTC

    It's always nice to bust out a Larry quote:

    Optimizations always bust things, because all optimizations are, in the long haul, a form of cheating, and cheaters eventually get caught.
    --Larry Wall

    Chris
    M-x auto-bs-mode

Re: Re: Golfing and Sprinting
by BrowserUk (Patriarch) on Mar 16, 2004 at 01:59 UTC

    Bravo!


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://336899]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-20 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found