Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^7: I have a list expanding when I don't want it to

by GrandFather (Saint)
on Nov 20, 2014 at 03:34 UTC ( [id://1107864]=note: print w/replies, xml ) Need Help??


in reply to Re^6: I have a list expanding when I don't want it to
in thread I have a list expanding when I don't want it to

I really don't want to get into a long debate about this but:

Because you are telling her, how she should program her code.

Isn't that in large part what Perlmonks is about? Or at least (because there is no code involved in this) offering well meant guidance.

And, (BTW) assuming (arrogantly) that she hasn't/didn't already profile both possibilities and choose appropriately.

Well, no actually. LA said "I thought about using delete, however the doc suggested emptying the lists would be faster.". No code involved. No test to see if there was a real issue. No consideration of which implementation might be easier to understand and maintain.

No attempt to help her. Just see the word (fast/er/est) and knee-jerk into patronizing dick mode.

Well, no actually. The advice offered was targeting the initial focus on speed instead of code clarity. Shaving a few micro seconds off something that only happens a few hundred times per execution of the script is almost certainly irrelevant.

In this particular case the code difference is likely to be small, but as a general thing concern over "the best way" can either make it almost impossible to make progress, or lead to very hard to maintain code that causes grief for ever. At $work an early coding decision for a C++ string object stores the actual string in a fashion that the debugger can't easily get at. At the time that probably made some string manipulations very slightly faster. Now compiler improvements mean that there is likely no performance advantage, but we get a major debugging disadvantage every time we want to see the contents of a string variable. The application using the string class does very little string manipulation so there is no performance improvement seen by users. The cost in developer time of that decision probably amounts to thousands of dollars.

So, I stand by my advice to LA and anyone else who bothers to read this far: Make it work first, then make it faster if you need to.

Perl is the programming world's equivalent of English
  • Comment on Re^7: I have a list expanding when I don't want it to

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found