Python versus Perl ?

Roy Smith roy at panix.com
Sun Feb 6 09:56:59 EST 2005


surfunbear at yahoo.com wrote:

>  I've read some posts on Perl versus Python and studied a bit of my
> Python book.
> 
>  I'm a software engineer, familiar with C++ objected oriented
> development, but have been using Perl because it is great for pattern
> matching, text processing, and automated testing. Our company is really
> fixated on risk managnemt and the only way I can do enough testing
> without working overtime (which some people have ended up doing) is by
> automating my testing. That's what got me started on Perl.

Automated testing is essential in almost any software project, and not just 
to make sure you don't have to work overtime.
 
>  I've read that many people prefer Python and that it is better than
> Perl. However, I want to ask a few other questions.

Keep in mind that this is a somewhat biased audience to ask a question like 
that.  For the most part, c.l.p. is inhabited by rabid Pythonistas :-)
 
> 1. Perl seems to have alot of packaged utilities available through
> CPAN, the comprehensive perl network.

There is no doubt that there's a lot of stuff on CPAN, and the architecture 
of the repository makes it relatively easy to find what you want and get it 
running.  On the other hand, there are a lot of add-on modules for Python 
too.  You mention DBI; Python's version of that is the DB-API, and there 
are quite a few modules that implement it 
(http://www.python.org/topics/database/modules.html).

> Perl also has excellent pattern matching compared to
> sed, not sure about how Python measures up,
> but this seems to make perl ideally suited to text processing.

As far as regular espressions themselves, Python supports exactly the same 
regex syntax that Perl does.  The packaging is a little different; instead 
of being built-in to the language, it's a module you import and use in an 
object-oriented way.

> 2. Python is apparantly better at object oriented. Perl has some kind
> of name spacing, I have used that in a limited way. Does Perl use a
> cheap and less than optimal Object oriented approach?

Python's OO support was designed-in from the ground up.  Perl's is an ugly 
wart held on with duct tape.

> That was what someone at work said, he advocates Python.
> Is it likely that Perl will improve it's object oriented features
> in the next few years ?

There is a "Perl 6" project going on, which I imagine will have some major 
changes to the language, but you'll have to ask the Perl people about that.

> 3. Perl is installed on our system and alot of other systems.
> You don't have to make sys admins go out of there way to make it
> available. It's usualy allready there.

Python now comes standard with a lot of operating systems, but it is 
certainly true that if there is one lingua franca in the computer world 
(and certainly the Unix world), Perl is it.  If your prime motivation is 
portability, that might be the feature which tips the balance in favor of 
Perl.

> I also did a search of job
> postings on a popular website. 108 jobs where listed that require
> knowledge of Perl, only 17 listed required Python. Becomeing more
> familiar with Perl might then be usefull for ones resume?

There is no doubt that most employers expect you to know Perl.  Even if 
it's not on the job spec, there's enough Perl out there in the world that 
it really is worth knowing.  If your career goal is sysadmin rather than 
programming, then I'd say Perl is absolutely essential to know.
 
> If Python is better than Perl, I'm curious how really significant
> those advantages are?

Well, now we're back to that biased audience stuff again.  My answer is 
that of course it's better.  The biggest advantage of Python is that it has 
a clean syntax with designed-in support of OOP.

Perl's basic syntax is a jumble of stuff stolen from shell, awk, sed, and 
grep, with some vague OO ideas glommed onto it.  The heavy reliance on 
punctuation makes it almost impossible to read.

My suggestion is to learn Python, then make up your own mind.  Grab one of 
the tutorials available on-line and spend an afternoon getting the basics 
down.  Next step, pick a small real-life project and invest a couple of 
days doing it in Python.  By then, you should have a better idea of whether 
it's worth investing some more time to get deeper into it.

One you know C++, Perl, and Python, you'll have exposure to a pretty broad 
range of programming paradigms.  But, don't stop there.  If your goal is to 
be a professional programmer, keep learning languages.  Learn some because 
they'll provide a paycheck, learn others because they'll expose you to 
different ideas.  In today's world, I'd put Java, SQL, VB, and C# in the 
"paycheck" group.  I'd put Lisp, Smalltalk, and Postscript in the "personal 
improvement" group.  Things like Python, Tcl, and Ruby fall somewhere 
in-between; they're interesting because they explore different corners of 
the "how to design a programming language" universe, but they also have a 
reasonable chance of being a skill which will keep the paychecks flowing.



More information about the Python-list mailing list