http://www.perlmonks.org?node_id=320777


in reply to All in one

Others have already commented on Perl's allowance for expressiveness, and I think that is a direct factor. Also there is the statement of 'less code equals less bug opportunities'.

Personally I have found myself doing the same thing, and at some point I step away and simply leave a #TODO: blah on the lines preceeding and move on. Other times I have fought the battle and won or lost. Every time I have found myself in this situation though, I end up in the docs. Just about everytime I'm in the docs poking around I tend to remember something I wanted to look up, or happen to read an entry I haven't seen before. I seem to always learn/refresh something during these times, which is always a good thing.

Is the behaviour right or wrong? Depends on the situation. There is a reason the terms 'magic' and 'deep magic' exist. Someone spent the time, somewhere, to figure out exactly how to get the best performance out of a given piece of code. What happens if someone spends the time now, wrestling with a few different problems along this line? Next time they encounter the same situation, they can pull from past experience and apply the knowledge now. Read be more efficient. Whether that be with less code, or less time spent due to already having an answer. Now look at the flip side. Eh.. it's good enough as is. Probably can't/shouldn't do anything else with it. Then something isn't fast/efficient enough and the crunch is on. Bad time to start attempting to streamline code.

Hacking code is, or should be in my opinion, fun. It's gratifying to be able to take something x lines long and reduce by y, while possibly adding functionality and/or abstraction at the same time. Someone's sig around here is something to the effect of 'I know I'm on the right path, when by deleting I'm adding functionality'.

</ramble>
Personally I think the behaviour should be encouraged. I don't think that answers should necessarily always be given to questions of this type, but rather general pointers about technique, and references to relevant docs/modules.

use perl;
Everyone should spend some time pounding nails with their forehead for a while before they graduate to complicated stuff like hammers. - Dominus

Replies are listed 'Best First'.
Re: Re: All in one
by ysth (Canon) on Jan 12, 2004 at 22:15 UTC
    Every time I have found myself in this situation though, I end up in the docs. Just about everytime I'm in the docs poking around I tend to remember something I wanted to look up, or happen to read an entry I haven't seen before. I seem to always learn/refresh something during these times, which is always a good thing.
    I think professional programmers should expect to spend %x percent of their time on improving their knowlege of their tools and %y percent of their time improving the tools themselves. Even under deadline. Insert x and y as appropriate for your situation; I like 10.