Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: The Rules of Optimization Club

by tinita (Parson)
on Mar 31, 2012 at 12:01 UTC ( #962764=note: print w/replies, xml ) Need Help??

in reply to The Rules of Optimization Club

I hope you realize how ironic this sounds in this forum. my typical usage here is: click on a thread, than switch tab to a different forum/rss feed/whatever, read 2 or 3 articles, then switch back to perlmonks where the thread has finished loading ;-)

first: I think everyone would agree that optimizing without having a clue is a waste of time. playing around with Benchmark and Devel::NYTProf can be really enlightening.
if you don't have a clue about algorithms and complexity you still can write programs that do what you want, that are well written in terms of maintainability and "fast enough".

but: if nobody ever cared about writing highly optimized perl modules, nobody would want to write applications and websites with it.

I'm actually sick of people warning about premature optimization over and over. in the last weeks I have been optimizing my forum software which has been running live for over three years. I did many different optimizations, and by logging the different request times and viewing them in munin graphs I could clearly see what kind of optimizations were more successful and which less.
I can estimate that some optimizations will be only worth if the website had more traffic. But that's no reason for not doing it. It's a software that I want to call "scalable".
I was talking about some of my thoughts in an IRC channel, and one person said to me that I was doing premature optimization. wtf?

so, yes: measure before or during optimization. if you are experienced though, often you don't need to measure beforehand.
but stop warning people about optimization in general.

Replies are listed 'Best First'.
Re^2: The Rules of Optimization Club
by petdance (Parson) on Apr 01, 2012 at 00:58 UTC
    I see far too many people trying to improve their execution speed when they have no business doing so.

    The node that prompted my posting the Rules of Optimization Club was this one (Print Vs Return In a Subroutine) where the writer wanted to know if it was faster to use print or return. If he wants real speed, he can call exit, too.

    The PHP world especially seems to be filled with people who worry about whether it's faster to use interpolation or concatenation to build strings, while tweaking a program that makes SQL queries against unindexed tables and returns the results over the Internet.

    It is for these people that the Rules of Optimization Club are most intended.


      I agree with that. it's just that I read people quoting the famous "premature optimization" thing way too often, and most of the time they forget to mention (or probably to even read) the rest of the quote.
      So I got really allergic to any "don't optimize" statements =)
        Nobody is saying don't optimize. In fact, I've never seen anyone say that "you should never optimize your code." If you can point me to someone who says that, I'd love to see it.

        It's all about what "premature" is.

        If your code is broken, then it's premature.

        If you don't know the costs of your code, it's premature.


Re^2: The Rules of Optimization Club
by BrowserUk (Pope) on Mar 31, 2012 at 12:42 UTC
    but stop warning people about optimization in general.


    My first reaction to accusations of "premature optimisation", is that the accuser is: a) aware of the limitations of their knowledge of the required techniques; b) aware of the techniques, but too lazy to pursue them; 3) a marketeer who'd rather sell you his latest gizmo, gadget -- be they software or hardware -- than show you how to make more effective use of the one you brought from him last year.

    Permute from the three.

    S'not always the case, but more often than not.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://962764]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-06-20 23:19 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.