[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell script or Perl?



On Thu, 12 Jun 2003 17:15:36 -0500
Kirk Strauser <kirk@strauser.com> wrote:
> At 2003-06-12T20:16:40Z, Steve Lamb <grey@dmiyu.org> writes:
 
> > Not this again.  *sigh* The point is that it is far too simple in Perl to
> > write s'ghetti code.
 
> Not this again, indeed.  I find a lot of shell scripts incomprehensible, but
> you seem to like them.  That's OK - it's your preference.  Please understand
> that not everyone sees it the same way.

    Uh, no, read my post where I said that for any given situation I prefer
Perl over Shell script.  I also happen to have worked with Perl for far too
long to fall into the trap that it is easily maintainable or easy to write
"clean" code.  I worked in a shop with strict coding standards with Perl as
our base glue language and of the three main Perl people (All with several
years of Perl experience) we loathed to touch anyone else's code because of
what I had described.

> > Furthermore it is far too simple for you to write what you may think is
> > "good code" and have another person who also has years of experience in
> > Perl have to stop, look and scratch their head at what you're doing.
 
> Go to http://www.honeypot.net/~kirk/projects/ and take a look at, say,
> "Antonym" or "Jail Management Software".  If you can read C, you can read my
> code.  I do *not* program in idiomatic Perl for the sole reason that I don't
> like to decipher idiomatic Perl, and I want to occasionally revisit my code,
> sometimes a year or more after I've last seen it.  I can open either of
> those programs and see exactly what they're supposed to do.

    Took me all of 2 minutes to find idiomatic code.

    unless (defined ($evblock{$opt{'alias'}}))
    {
        exitWithError("Alias \"$opt{'alias'}\" is not configured.");
    }


    We'll forgive the fact you have no consistant way to set way to use parens
(sometimes you use them, sometimes you don't, someitmes when you do you have
spaces between the parens and the caller, sometimes you don't) this right
here is the prime example of idiomatic Perl that causes problems. I never use
unless. Why? First off every other language does if not, not unless. Secondly
you cannot else an unless. If you ever needed to alter this to show something
else you would have to first convert it to an if not and then tack on the else
or elsif.

> You're entitled to your opinion.  I may not reflect on my experiences in any
> way, but you're still free to have it.

    My opinions, however, I can back up with examples from your own code. 
Examples which I can explain why the code is inconsistant and hard to read
yet, in Perl, it is considered correct, accurate and "good".  You used an
idiom without even knowing it and profressed to not use idiomatic Perl!

> My main point is that you *can't* say "X is easier to maintain than Y",
> because I can guarantee that Y's fans will completely disagree with you.
> I'd much rather have to maintain a legacy Perl program than anything in a
> shell language, but not that I have *not* blanketly stated that shell
> programming is bad, ugly, or unmaintainable.

    I agree.  I think shell is difficult to maintain because of the overly
complex rules on parameter passing.  At least when I unlink($foo) I don't have
to worry if $foo is '/ -rf' and be paranoid about it as I do in shell script.

    However, having said that I also prefer Python over Perl for the simple
fact that it is far more readable than Perl and you don't have the
multiple correct ways to do something Perl has.  Furthermore I have written
multi-threaded test scripts without commens that did the same thing as our
in-house Perl scripts had people who neither wrote Perl or Python come over
and tell me in 30s what it did.  That, sir, is readable.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
	                       |    -- Lenny Nero - Strange Days
-------------------------------+---------------------------------------------

Attachment: pgpFiQ9nLCDtt.pgp
Description: PGP signature


Reply to: