Readable Perl (was Re: Python vs. Perl, which is better to learn?)

Peter Hansen peter at engcorp.com
Mon May 6 20:10:12 EDT 2002


George Demmy wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> > More out of curiosity than an intention of starting a flame war, but
> > would someone post a snippet of twenty or so lines of Perl which they
> > believe is "readable"?
> >
> This is a link to a bunch of perl code that is really quite readable,
> IMHO.
> 
> http://www.dnalounge.com/backstage/src/

Thanks very much George.  I was especially interested in the 
switcher-cmd.pl file, since it is similar in general purpose 
to many pieces of Python code we've written here (interfacing
with external equipment via serial ports, parsing commands...).

I have to say that is the least ugly Perl code I've ever
seen.  I was going to say "prettiest" but I really can't bring
myself to say that.  The line noise just makes it so much more
difficult to parse at a glance.

Maybe if I were a more experienced Perl programmer I would 
agree that it's "readable", but I can only say that in comparison
to Python, I still find that code very hard to absorb without
staring at every few lines hard for many seconds.  With Python
I can skim through a file that size in ten or twenty seconds
and have a basic idea how to navigate it.  I can glance at a
function for a few seconds and pretty much know what it is
expected to do.  I can review a couple of lines of code in
a few seconds and generally be confident it is written correctly.
With the Perl code, those numbers go up almost an order of
magnitude (for me).

But it is very impressive, for Perl code.  My compliments to
the author.  Any perceived lack of readability is clearly the
language's (and reader's) fault, not the author's.

-Peter



More information about the Python-list mailing list