Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Here's Paul's comment and footnote in their entirety:
    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. [7]

    [7] The way to make programs easy to read is not to stuff them with comments. I would take Abelson and Sussman's quote a step further. Programming languages should be designed to express algorithms, and only incidentally to tell computers how to execute them. A good programming language ought to be better for explaining software than English. You should only need comments when there is some kind of kludge you need to warn readers about, just as on a road there are only arrows on parts with unexpectedly sharp curves.

    Knowing Paul's background is as a lisp hacker, I would hazard a guess that the readers he's talking about are not people deeply steeped in Perl, but people who will dabble with Perl on occasion, and not get too deeply attached to any language other than Lisp. From that perspective, Perl is a little befuddling, what with all of the special variables and contexts. For example, it may make total sense to you today that $|++ is the magic incantation to turn off output buffering, but six months from now, deleting that seemingly innocuous do-nothing assignment actually changes the behavior of the program in a way you would not have predicted.

    Perl is like that, because Perl is optimized in different axes. If you are comfortable with C, sh, awk, or other languages that are more popular than Lisp, the syntax will be somewhat comforting and easy to pick up. If you spend enough time with it to consider yourself a Perl programmer (rather than a programmer who hacks on the odd Perl script now and again), the little idiosyncracies will be simple concise statements of purpose (like the difference between $count=@list vs. ($first)=@list).

    Perl is different in this respect. It's not unique, because there are some dark corners in C++ that I wouldn't want to visit even if Aragorn and the entire army of Middle Earth was on my side leaving comments along the way as they prepared to battle the compiler. And, no offense to John McCarthy, but Lisp only starts to make sense once you've drunk deeply from the magic bowl of Lambda flavored Kool-Aid and convinced yourself that the smell is much worse than the taste.

    Add all that up and what do you get? Comments won't save you, and if you're not interested in joining the church of Perl, you may need more comments than average to Perl's context and special variables straight in your head.