in reply to Clever vs. Readable
Considering the poor maintainer (probably oneself), I would vote for readability most of the time. However, shorter code sometimes executes faster (the OPs example probably not). E.g., I think of something with implicit loops like map{...} which gave me some problems decoding when I was a Perl beginner.
If terse code is a must, proper commenting is 'more' mandatory.
Consider this:
$result = ($a, $b)[$b <= $a]; # minimum ($a, $b)
Less than 20 additional characters read in a fraction of a second helps to
save some dozens seconds decoding and the uncomfortable feeling to have something missed. From my point of view, clever is okay when there is a gain, be it speed of execution or degree of obfuscation.
|