Re: confusing Perl idioms and practices

2001-06-29 Thread Aaron Craig

At 11:01 28.06.2001 -0700, Peter Scott wrote:

Readable is like obscene (in more ways than one, in some code I've 
seen).  I spent a little time in my book (one day I hope to have to say 
which book :-) going over pros and cons of different takes on this.  But 
as it stands, readable is simply meaningless, and guaranteed to cause 
friction.  Your elaboration doesn't help either.  Readable is only 
meaningful in a context of how the code is going to be used and what your 
tactical and strategic goals are.  Debating it in a virtual vacuum like 
this is what I call a pinhead discusssion - how many angels can dance on 
the head of a pin...

If you define readable as simple enough for the extreme beginner to 
understand, I agree.  This is not only obscene, it also makes it 
impossible to take full advantage of the language, as some constructs are 
necessarily complicated, and require a firm understanding of Perl to decipher.

However, I think a general level of non-obfuscation can be reached.  When 
working in groups, it becomes a necessity.  It's a matter of finding a 
common style in the group.  This saves time when someone is on vacation and 
you have to fix a bug in their code.  If they go around naming variables $x 
and $y instead of $names and $sizes (or, even better, $raNames and 
$raSizes), you spend a lot of time just figuring out what's going on.  Many 
will argue (correctly) that no decent programmer would name his or her 
variables $x and $y outside of a for loop.  However, rejecting readability 
out of hand as catering to beginners leads to similar behavior.  I always 
prefer an extra line of code in the spirit of readability.  If nothing 
else, it saves me from getting phone calls when I should be laying on the 
beach :)


Aaron Craig
Programming
iSoftitler.com




Re: confusing Perl idioms and practices

2001-06-29 Thread Randal L. Schwartz

 Aaron == Aaron Craig [EMAIL PROTECTED] writes:

Aaron If you define readable as simple enough for the extreme beginner to
Aaron understand, I agree.  This is not only obscene, it also makes it
Aaron impossible to take full advantage of the language, as some constructs
Aaron are necessarily complicated, and require a firm understanding of Perl
Aaron to decipher.

I'll second this.  In our professional code reviews, I have no problem
with requiring the maintenance programmer to know everything in
Learning Perl, plus whatever they can grok from perlreftut and
perlboot, plus some problem-domain-specific information.  However, if
someone is being particularly obscure, there'd better be a reason:
either there's a performance advantage, in which case the obfuscation
must be documented precisely, or it's gotta be simplified before it
passes.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[EMAIL PROTECTED] URL:http://www.stonehenge.com/merlyn/
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: confusing Perl idioms and practices

2001-06-28 Thread Peter Scott

At 09:52 AM 6/28/01 -0700, Gregg Williams wrote:

Hi--I recently posted a message titled writing readable Perl. In it, I
said:

snip

This is a simple example--too simple for some--but it gives you an idea of
what I'm looking for. Thanks again for your time.

Readable is like obscene (in more ways than one, in some code I've 
seen).  I spent a little time in my book (one day I hope to have to say 
which book :-) going over pros and cons of different takes on this.  But as 
it stands, readable is simply meaningless, and guaranteed to cause 
friction.  Your elaboration doesn't help either.  Readable is only 
meaningful in a context of how the code is going to be used and what your 
tactical and strategic goals are.  Debating it in a virtual vacuum like 
this is what I call a pinhead discusssion - how many angels can dance on 
the head of a pin...

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com