Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: On Golf

by Cybercosis (Monk)
on May 21, 2001 at 06:05 UTC ( [id://81898]=note: print w/replies, xml ) Need Help??


in reply to On Golf

This is actually a quote by Dijkstra (sp? and I forgot his first name), and I had a similar response when I first read it (in a rather wonderful book entitled Classics in Computer Programming (I think...)). Less symbols means less code, so it's optimization, which is of incredible conceptual importance (particularly when generating code rather than writing it. I'm starting to sympathize with the poor guys who had to write the first assemblers in machine code...). Oh well, one can't expect the man to be right all the time.

~Cybercosis

Replies are listed 'Best First'.
Re: Re: On Golf
by willdooUK (Beadle) on May 21, 2001 at 14:40 UTC
    > Less symbols means less code, so it's optimization

    Can't good optimization sometimes increase the number of symbols in your code (assuming you're not working in assembler)?

    You can have verbose code that is highly optimized in that it avoids any expensive processes, and you can have short, compact code that actually translates to expensive machine code.

    On any high level language like Perl, the code is never going to map directly to the same quantity of machine instructions.

    All I'm saying is that anything done in the name of optimization has to be considered from the machines point of view.

    willdooUK
    --------------
      Just to add to this, in C, a for-loop is smaller but less optimized than writing out each statement seperately.

      And using cos() or other trig functions might be smaller but a lookup table is much faster.

      When you're not specifically dealing with instructions, code size doesn't really have any correlation to speed.

      Rich

        Just to beat a dead horse:

        in C, a for-loop is smaller but less optimized than writing out each statement seperately.

        ...unless the unrolled loop's extra code size causes a cache miss across a slow bus, in which case the for-loop is more optimized (assuming, of course, that the loop fits in a cache line).

        --
        F o x t r o t U n i f o r m
        Found a typo in this node? /msg me
        % man 3 strfry

      I agree completely. However, optimization can mean any of several different things; you can optimize for speed, readability, size, footprint, or whatever. What is more important than the actual direction of optimization is mastering the process of thought involved in optimization.

      ~Cybercosis

      nemo accipere quod non merere

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-09-07 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.