Perl: the Markov chain saw | |
PerlMonks |
Re^7: I have a list expanding when I don't want it toby GrandFather (Saint) |
on Nov 20, 2014 at 03:34 UTC ( [id://1107864]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|