Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: "Cleverness" from HOP

by ikegami (Patriarch)
on Jun 11, 2009 at 17:32 UTC ( [id://770710]=note: print w/replies, xml ) Need Help??


in reply to Re^2: "Cleverness" from HOP
in thread "Cleverness" from HOP

Simplicity is subjective.

To someone who is equally familiar with A, B, C, D, E, F, ABCD is less simple than EF.

To someone who is more familiar with A, B, C, D than with E, F, ABCD is more simple than EF.

The simplicity of the building blocks is not an indication of the simplicity of the whole.

As concrete example, compare

my @a; for my $b (@b) { push @a, process($b); }
and
my @a = map process($_), @b;

I consider the latter simpler or at least equally simple, but others consider it more clever since they haven't dealt with map or they aren't used to dealing with map.

Replies are listed 'Best First'.
Re^4: "Cleverness" from HOP
by demerphq (Chancellor) on Jun 14, 2009 at 10:28 UTC

    Im with you on this for sure. All too often programmers with a poor understanding of Perl label idiomatic and efficient, and elegant Perl structures with "cleverness", when in fact what they are really saying "you wrote something im too lazy to understand so it must be bad". And actually the first code is not the same as the second in various subtle ways, starting with the fact that it performs many more opcodes that the one following, and thus is not going to be as fast (perl bugs aside).

    Bad cleverness is writing a cache system for something that doesnt need to be cached, or using some funky algorithm when a plain array would do. Its not about using the language expressively.

    ---
    $world=~s/war/peace/g

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 04:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found