[oclug] Why Perl is a Bad Language
Kirrily Robert
skud at e-smith.com
Thu Feb 22 16:33:17 EST 2001
On Thu, Feb 22, 2001 at 03:34:51PM -0500, Dave O'Neill wrote:
> On Thu, 22 Feb 2001, Francis Pinteric wrote:
>
> > Yawn! Ok, quoting St. Augustine is not reasoned. Ok, let's quote
> > Larry Wahl himself: "Perl is a mess. It's a mess because the problem
> > space is also a mess." By problem space he's talking here
> > specifically about webpage design and other internet stuff.
>
> ( It's "Wall", not "Wahl" )
>
> > There are complaints about whether or not Perl is really the tool for
> > XML (http://www.xml.com/pub/2000/10/11/perlxml/index.html).
>
> What that article boils down to is "Right now, people who use Perl aren't
> really people who use XML, so let's fix it". It's certainly not a
> condemnation of the Perl language by any means.
>
> Personally, I've used Perl with XML in rapid-prototyping situations with
> zero problems.
I rather like the XML::Simple module:
use XML::Simple;
my $ref = XMLin("myfile.xml");
print $ref->{$element-you-want};
In a project I'm working on at the moment, we're using XML::Parser which
is more complex, but which returns data which is better structured to
our needs (ordering was important to our application, for instance, and
XML::Simple doesn't keep the order because hashes are inherently
unordered).
Both of these modules are built on top of expat, if I recall correctly.
> This boils down to "Use the right tool for the job". Perl isn't always
> the right tool. Neither is C, or C++ or Java or Bash scripting, or ....
> How does this make Perl a bad language? It doesn't, no more than any
> other.
*nod*. Sometimes Perl simply isn't an appropriate tool for the job.
However, these instances are less common with Perl than with many other
languages.
> Perl isn't so good at being readable and understandable by beginners.
That depends quite a bit on whose code it is :) I've spent a couple of
years teaching Perl to both newbie programmers and those with experience
in other languages, and most of them seem to get the hang of it very
quickly.
> It's
> certainly not a good first programming language.
I'd usually agree with this. When I was teaching Perl courses, we used
to recommend that programmers have at least one language under their
belt before they tried it. The real reason for this is not because Perl
is hard to learn, but because the things that are best about Perl are
kind of reactionary... Perl is good because it makes things *easier*
than other languages, and you won't understand that unless you know the
other languages. An example is variable interpolation... you won't
realise why:
print "The key is $key and the value is $hash{$key}";
is good unless you've had to do:
print "The key is " + $key + " and the value is " + $hash{$key}
Yeah, I know that's not any identifiable language (it's vaguely Visual
Basic, I think :)) ... but it demonstrates what I mean. Incidentally, I
made two errors when I first typed in that line. I put:
print "The key is" + $key + " and the value is " $hash{$key}
(a missing space after the first "is" and a missing plus sign). Those
were the sort of errors I made all the time when programming in
languages that used similar syntax, and I know I'm not the only one.
One of Perl's mottos is "make easy things easy, and hard things
possible". Interpolating variables verbatim into a string you're going to
print out *should* be easy, so Perl makes it easy.
> It's also easy to write
> unmaintainable code in Perl, though Perl is certainly not alone in this
> regard.
You can write INTERCAL in any language :)
> For performance-critical applications, or ones that require a
> small memory footprint, Perl probably isn't a good idea either.
True. But this doesn't describe most of the applications Perl is used
for. The exception is heavy use web applications, and that's what
mod_perl is for. Considering some of the other options I've seen
(Oracle webserver springs to mind, ugh), Perl's not so bad :) But I
agree that I wouldn't want to be trying to write embedded apps in it or
anything like that. Though I do have a friend porting it to the Palm
Pilot :)
> Perl also
> lacks a "clean" OO syntax, and some nice OO features, like interfaces and
> private member variables and functions, making OO programming in Perl more
> difficult than it should be.
The OO syntax is likely to be getting a workover in Perl 6... we know
it's a kludge :) But it's also not likely to end up as something that
appeals to the Eiffel programmers out there, so it may still upset the
purists.
> The language also enforces very little in the way of policy. If you want
> to implement your objects as an anonymous scalar, go right ahead. If you
> want to format your code blocks all on one line, do it. This is both a
> blessing and a curse, and at times, both.
My take on this is that good programmers program well in any language,
but bad programmers will program badly in any language. If you're the
sort of programmer who doesn't realise that formatting your code block
all in one line is bad, then you're unlikely to have the skill or
experience to understand algorithm design or any of the other more
fundamental things you need to write good programs.
The thing about Perl vs $programming_language is that it's like every
other holy war: essentially boring, repetitive, and unlikely to sway the
opinions of anyone involved. I tend to be moderately relaxed about such
things: if you don't like Perl, that's fine, use something else. I
won't stop you, and I won't even try hard to convince you once I know
your opinions are firmly set. Just so long as you let me get on with my
life, too :) (Generic "you" throughout that para, btw)
Speaking of which, I really ought to get back to hacking. I want to get
the latest release of my XML app out the door today or tomorrow.
To the rest of the disputants in this thread: what GPL'd software are
*you* releasing this week? If not, why not?
K.
--
Kirrily "Skud" Robert
skud at e-smith.com (work)
skud at infotrope.net (home)
More information about the OCLUG
mailing list