Why are people always trying to accomplish things "all in one statement" or "all in one regular expression"? Usually when I see these questions it gives me the impression that the asker can think of a way to do it, but it would take two statements/expressions (and that would just be too many!). And often times it's on IRC where by the time they've asked the question and gotten an answer (which probably consists of "why don't you just use two statements?"), they could have already coded something that would have worked but not taken only one statement/expression.
Is this an instance of premature optimization? Do they believe in the false economy that "less text" equates to "more efficient code"? Or perhaps as delirium's meditation seems to imply, they think that "less text" equates to "more elegant code"? Granted, there are some instances where it would make the code read better if there were a way to get some complex functionality into one expression, but you know what? We already have a way to do that; they're called subroutines. I think people need to realize that clarity trumps cleverness always (okay, except when your goal is cleverness like with golf or obfuscations)
Or is that it right there? Perl has a reputation of being clever, so users always want to do something clever in their code.
Where do you guys think this pervasive meme comes from? And are current methods of education stemming the tide of ignorance?
In reply to All in one by duff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |