[Pdx-pm] Readable code

James marks jamarks at jamarks.com
Mon Jan 10 22:55:56 PST 2005

Greetings all,

I'm new to Perl and fairly new to programming as well and I'd like to 
pose a question for all of you experienced and knowledgeable Perl 

Recently, a number of books I've read about, or referring to, writing 
code - Steve McConnell's "Code Complete" and Paul Graham's "Hackers and 
Painters," are two examples - emphasize writing readable code. An 
excerpt from "Hackers and Painters" illustrates my  point:

"Source code, too, should explain itself. If I could get people to 
remember just one quote about programming, it would be the one at the 
beginning of Structure and Interpretation of Computer Programs.

" 'Programs should be written for people to read, and only incidentally 
for machines to execute.' "

You need to have empathy not just for your users, but for your readers. 
It's in your interest, because you'll be one of them. Many a hacker has 
written a program only to find on returning to it six months later that 
he has no idea how it works. I know several people who've sworn off 
Perl after such experiences."

I've gotten in the habit of breaking my code out into lots of 
subroutines because I've found that makes it much easier for me to read 
and troubleshoot, a practice that seemed to be reinforced in Code 
Complete. Now, however, as I read books on Perl and talk to Perl coders 
I'm finding that placing an emphasis on writing readable code, and 
breaking code out into lots of subroutines doesn't seem to be 
considered "the Perl way" of doing things. The emphasis seems to be 
tighter and tighter code, sometimes - it seems to me - at the expense 
of readability (especially for those new to Perl).

I'd be very interested in your thoughts and suggestions regarding terse 
code, readable code, verbose code, etc...



More information about the Pdx-pm-list mailing list