Why use Perl when we've got Python?!

Sam Holden sholden at pgrad.cs.usyd.edu.au
Sat Aug 14 22:10:03 EDT 1999

On Sat, 14 Aug 1999 12:06:11 +0100, Alex Maranda <amaranda at nospam.com> wrote:
>Sam Holden wrote: 
>> >
>> >>You can write Perl programs that resemble sed, or awk, or C, or Lisp, or
>> >>Python. This is Officially Okay in Perl culture.
>> >
>> >You cannot write Perl that resemble Python.  You are required to
>> >use curly braces as block delimiters.
>> In fact you are not. You are wrong yet again. Actually thinking about how
>> perl works for a minute would show you that perl is in fact flexible.
>> it is not a lie when people say perl doesn't force you to write a
>> particular way.

<snip impythonate.pm by Damian Conway>

>> And here is his sample code that is now valid perl (although anyone who uses
>> it for real code should be killed) :
>Why? You don't happen to hate Pythoneers or Python itself, do you? I've
>actually appreciated the argument from your second post, when you taxed
>the other guy for needlessly questioning your Python knowledge out of

I know a fair few pythoners in fact, I even like some of them. What I meant
was that anyone who would do such a thing with perl deserves to be killed.
Since no one else will be able to maintain the program. It's like someone
who starts a C program with :

#define BEGIN {
#define END }

Doing things like this means that a C programmer can't understand the code,
and a Pascal programmer can't either. With impythonate.pm, a perl
programmer can't understand the code, and a python programmer can't either.

Also don't tell anyone but I actually like python a lot. I don't use it much
since I have more experience with perl, and more importantly I know the
modules available for perl better, and can quickly search for one to
do whatever I need next.

>I am completely ignorant with Perl and I can barely read what's above
>(by interpolating my knowledge of shell, C, and Tcl).

That's because it uses a lot of the not so well known perl features. 

>> #Now newlines replace colons and indentation replaces brackets:
>> for $i (1..10)  # COMMENTS ARE OKAY
>>   print "$i: "
>>   my $isq =  \
>>   print " $isq\n"
>> print "done\n"
>I know Python fairly well (but I'm no expert) and I can easily read this
>piece of Perl.

But it would be no harder to read with ; on the end of each statement and
a pair of {}s.

Working out that strings interpolate should be a bigger leap than working
out that blocks have {}s around them.

> Getting back to the killing part, which kind of disturbs
>me when reading comp.lang.python:
>- was that necessary to make a point?
>- if yes, what was the point?
>- if the point (just guessing) was that Perl code should never look like
>Python, isn't that against of 'there should be more ways of doing it?'

I answered this above a little.

It was necessary since I don't want someone actually using such an untested
module in their code. Chances are it breaks on many python constructs. The
obvious example is :

if (1==1) : print "fred"

It won't handle that.

Everyone seems to misunderstand the whole concept of TMTOWTDI. It doesn't
mean all ways are equal. That is a way of writing perl which works, it is
however not very maintanable. The only way to determine what syntax is
valid is to know perl's syntax, and to be able to read and understand the
impythonate.pm code - since there is no documentation and it is _not_ the
same as python.

Writing it in 'normal' perl reduces the requirements to understanding, and
speeds it up to boot.

>I fail to see the interesting part in this whole thread, which disturbs
>the habitat of comp.lang.python. I think John Stevens was mistaken to
>bring the discussion over to this newsgroup in the first place. We don't
>have strong feelings about Perl, and don't have plans for world
>domination or anything.
>A couple of days ago I read a bit in Bugzilla's README which amused me:
>"A computer which doesn't have Perl installed is a very sad computer
>indeed". Your post is frightening (unless it was a Perl-style joke).

How was it frightening?

If you want to program in python, then use python. It's a nice language,
it is portable, it is simple to install, it is easy to learn. 

So what is the point of munging another language to look like it? If you could
munge perl so that you could name the capturing elements of a regex then that
would be a useful, python like addition...


There's no such thing as a simple cache bug.
	--Rob Pike

More information about the Python-list mailing list