Python versus Perl

Terry Hancock hancock at anansispaceworks.com
Wed Sep 7 10:37:41 EDT 2005


On Wednesday 07 September 2005 04:47 am, Michael Sparks wrote:
> Dieter Vanderelst wrote:
> > I'm currently comparing Python versus Perl to use in a project that
> > involved a lot of text processing. I'm trying to determine what the
> > most efficient language would be for our purposes. I have to admit
> > that, although I'm very familiar with Python, I'm complete Perl noob
> > (and I hope to stay one) which is reflected in my questions.

> Your comment """I'm complete Perl noob (and I hope to stay one) """
> would suggest to me that if you really feel that way, stay that way :-)

I missed that on the first reading.  IMHO, people love perl *really*
because it was the first language of its type.  However, we learned
a lot from that experience, and have since made better languages
in the same general category. The best of these of course, is
Python. ;-)

I felt that way about C, and occasionally Fortran.  But I've gotten
over it. ;-)

I took Perl classes after I learned Python, and I haven't found
anything Perl is enough better suited to do that it is worth the
trouble of messing with it.  Yes, the one and two liner programs are
nice, but now that six months have passed and I can no longer remember
Perl syntax, it's a lot easier to do it in Python, even if I do wind
up using, say, 4 lines of code.

The biggest distinction I got from looking at Perl from the perspective
of Python is that:

1) Perl makes regular expressions first-class objects, which makes them
really easy to use, and a "beginner" subject in a Perl class.

2) Python makes objects and classes really easy to use, so they are a
"beginner" subject.

However, each can do the other when pressed. So which would you rather
have be easy?

Regular expression program makes huge incomprehensible piles of
gobblygook which you forget 10 seconds after you wrote it, while
objects and classes make it easy to understand the structure of
your program.

Even regular expressions are clearer in Python (IMHO) because of the
ability to apply string operations on them.  Furthermore, the ready
availability of more direct methods of string manipulation encourages
more optimized and clearer design decisions (in Python if you just
want to find a word, you can just say so, instead of "crafting a 
routine regular expression").

Performance is a complete non-issue. Both languages are reasonably
fast, and neither has a clear advantage on real world projects. Python
and Perl are "rivals" precisely because they are very similar in what
they can do.

So I'd second the suggestion to eschew the Perl if you can at all
get away with it.  If you're already sold on Python, there's no
reason to question your judgement.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Python-list mailing list