in reply to Meaning of Maintanability and Functionality in Coding Perl

I would add a few other trivial pieces of advice:

You're not writing code for the Obfuscated Perl contest (would any sensible programming manager hire somebody who put "winner 4 years on a row in the World Obfuscated <language of choice> contest" as a major award in their resume?).

Try to avoid Perlisms like the assumption that if(/.../) applies to $_. Be explicit, even if it looks "wordy" or "overly verbose".

Add use English, and use the English language forms for things like $|. (If there aren't use modules for other major languages, maybe there should be).

Find a coworker and have her or him try to figure out what you were doing, without your assistance.

Please, please, please, make comments meaningful, useful, properly spelled, and grammatical.

emc

  • Comment on Re: Meaning of Maintanability and Functionality in Coding Perl

Replies are listed 'Best First'.
Re^2: Meaning of Maintanability and Functionality in Coding Perl
by Anonymous Monk on Oct 18, 2005 at 18:34 UTC
    Try to avoid Perlisms...
    Why would you bother to use the perl interpreter if you want to write in some other language. That's only going to confuse real Perl programmers. There are plenty of other languages to choose from. Idioms are there for a reason.
    ...like the assumption that if(/.../) applies to $_.
    Why is this an assumption? Is there any time when m/.../ doesn't match against $_?

      Every language has its esoterica and every language has features that make future maintenance more challenging than it should be. I'm not saying never use substr as an lvalue; I'm saying (turgidly, perhaps) is that idiom should be eschewed if it conflicts with clarity.

      I doubt if writing
      if($current_line =~ m/abc/)
      will confuse a real Perl programmer, just as I doubt that
      DO LOOP_COUNTER = START, FINISH
      will confuse a real Fortran programmer.
      Why not write
       DO I=J,K
      instead?

      I will agree idioms are there for a reason, but the idioms are not the language. Fortran, a language I've dealt with for several decades, has all sorts of idioms which are generally considered Bad Things. Most corporate style guides forbid Fortran programmers from using computed and assigned gotos and arithmetic if statements, both perfectly legitimate idioms. Perl has a goto; it's there for a reason, but that doesn't make its use a good idea.

      emc

Re^2: Meaning of Maintanability and Functionality in Coding Perl
by Anonymous Monk on Oct 18, 2005 at 18:47 UTC
    You're not writing code for the Obfuscated Perl contest (would any sensible programming manager hire somebody who put "winner 4 years on a row in the World Obfuscated <language of choice> contest" as a major award in their resume?).
    Aren't the winners of those contests the ones who are the most intimate with the given language? Note that Mr. Wall has won an IOCCC award, not once, but twice.
    Add use English, and use the English language forms for things like $|.
    use English does signify one important fact; the code that follows was written by a complete Perl newbie. And that's important information for any maintainer.
      use English does signify one important fact; the code that follows was written by a complete Perl newbie. And that's important information for any maintainer

      Frequently code maintenance is performed by programmers with little experience or little experience in the language. Even if the original programmer has eons of Perl experience, the person maintaining the code may be trying to figure out a Perl program with Learning Perl by one elbow.

      Aren't the winners of those contests the ones who are the most intimate with the given language? Note that Mr. Wall has won an IOCCC award, not once, but twice.

      I've never read Lary Wall's resume...does he consider winning the IOCCC contest a major achievement? Again, the chances are the maintainers are less experienced than the original programmers. Eschew esoterica.

      emc