[prog] Programming for QA folks

Jacinta Richardson jarich at perltraining.com.au
Sat Jun 16 13:46:22 UTC 2007


Miriam English wrote:

> Perl can be extremely difficult to read later. This becomes very 
> important when you collaborate in a group or have to return to your own 
> code after months, when it might as well have been written by someone 
> else. Perl tends to be extremely dense and obscure, and easily hides 
> annoying little bugs because of that.

I suspect you're complaining about bad programmers here, rather than a bad 
language.  Sure, Perl doesn't insist on the programmer using multi-syllabic 
variable names, consistent indentation etc; but neither does C, Java, PHP and 
others and they don't get the rap Perl has.  A good programmer can write 
beautiful, maintainable and well readable code in almost any language (once 
they've learned it).  Perl has a historical reputation for ugliness (quite 
probably because it wasn't originally designed for _programmers_), but _good_ 
Perl programmers probably write ugly Perl code as often as _good_ Python 
programmers write ugly Python.  And when they do write ugly code, at least they 
can use perltidy to improve it.  :)

Perl does make it easy to write line-noise, but I don't know of anyone who 
recommends that you do so (except for obfuscated contests).  Perl does have ugly 
global variables like the ones you see a lot:
	$_, @_, $/, $@, %ENV, @ARGV, $0 - $9999999
and even more that you should never see (refer to perldoc perlvar). Many of 
these special variables come from Perl's roots back 20 years ago.  Back then 
Perl's author took a bunch of existing Unix tools (sed, awk, shell and others) 
and glued them all together into a language.  Perl became popular almost 
immediately with system administrators who then used it for pretty much 
everything.  As a result later versions of Perl have meticulously maintained 
backwards compatibility with this first version.  (Perl 6 finally breaks this 
compatibility, but then it's almost a whole new language).

Good programming techniques have changed a lot in the last 20 years and so has 
Perl.  Perl's had a style guide for years and the "Perl Best Practices" book was 
published two years ago - I was a technical editor - (I know a bunch of PHP 
programmers who follow most of it's advice too).  Perl is about as dense and 
obscure as _you_ write it.

Cryptic programmers are compatible with any language and anyone who writes 
cryptic code is doing themselves a disservice.  In fact, as I read in Perl Best 
Practices; writing good code is like writing a love letter to your future 
self...  :)  And I think it was Dijkstra who observed that in order to be able 
to debug code you have to be twice as smart as the original author; so if you 
write tricky code, you'll never be smart enough to debug it!  These are all true 
for any language.

All the best

	Jacinta



More information about the Programming mailing list