Perl Versus Python

S

surfunbear

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.

I've read that many people prefer Python and that it is better than
Perl. However, I want to ask a few other questions.


1. Perl seems to have alot of packaged utilities available through
CPAN, the comprehensive perl network. These can aid in building
parsers, web development, perl DBI is heavily used. This seems to be a
very important benifit. I'm not sure that Python is as extenive at all
in that regard ? 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.

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 ?
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 ?

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. 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 ?



If Python is better than Perl, I'm curious how really significant
those advantages are ?
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g14g2000cwa.googlegroups.com:
I'm a software engineer, familiar with C++ objected oriented
development,

Good for you.

....
I've read that many people prefer Python and that it is better than
Perl. However, I want to ask a few other questions.

This is a FAQ. Please see:

perldoc -q "How does Perl compare"

Sinan
 
D

David Trudgett

I've read some posts on Perl versus Python and studied a bit of my
Python book.

Hey, you didn't even cross post to the Python newsgroup! How's a
language war supposed to start like that?? :)

David
 
S

Sherm Pendley

1. Perl seems to have alot of packaged utilities available through
CPAN, the comprehensive perl network.

In my opinion, CPAN is Perl's major advantage. With CPAN, the question
becomes less about the code you write, and more about the code you *don't*
write.
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 ?

That's a matter of philosophy. Perl allows a clean OO approach - but it
doesn't require it. For my part, I do OO in Perl all the time, and I don't
have a problem with it.

I find it puzzling that some folks need a language that forcibly prevents
them from crossing object boundaries - why can't they simply refrain from
doing so on their own? If they can't, isn't that their own weakness, not
that of the language they're using?

sherm--
 
A

Anno Siegel

Sherm Pendley said:
(e-mail address removed) wrote:
That's a matter of philosophy. Perl allows a clean OO approach - but it
doesn't require it. For my part, I do OO in Perl all the time, and I don't
have a problem with it.

So do I -- as long as I deal with my own code.
I find it puzzling that some folks need a language that forcibly prevents
them from crossing object boundaries - why can't they simply refrain from
doing so on their own?

They don't, that's the problem. In particular, some authors of classes
published on CPAN don't. Perl lets you drag stuff in and out of an object
willy-nilly, so that's what people do, making clean inheritance harder
than it has to be. I for one would be glad about a way to enforce the
definition of accessors and their use throughout the rest of a class.
If they can't, isn't that their own weakness, not
that of the language they're using?

Well, yes, but the weakness becomes a weakness of available software.
It wouldn't be an entirely bad thing if OO newbies had something in
Perl to stiffen their backs. In Perl, you must know how to do it the
OO way. In Python, I understand, there is no other.

Anno
 
S

Sherm Pendley

Anno said:
They don't, that's the problem. In particular, some authors of classes
published on CPAN don't. Perl lets you drag stuff in and out of an object
willy-nilly, so that's what people do, making clean inheritance harder
than it has to be. I for one would be glad about a way to enforce the
definition of accessors and their use throughout the rest of a class.

I prefer the approach taken by Cocoa/Objective-C. Objective-C does offer
both "private" and "protected" modifiers, but they're trivially simple to
bypass with a type cast.

Few people actually do so, because there are a number of tangible benefits
to be gained by writing and using accessors that follow a simple design
pattern. The pattern is pervasive through all of Cocoa, and using it in
your own code makes a number of things Just Work - key-value coding
observing, serialization, Cocoa bindings, etc.

In short, if Perl's approach has a weakness, I don't think it's the lack of
a stick, but rather the lack of a tasty carrot.

sherm--
 
A

Anno Siegel

Sherm Pendley said:
I prefer the approach taken by Cocoa/Objective-C. Objective-C does offer
both "private" and "protected" modifiers, but they're trivially simple to
bypass with a type cast.
Okay...

Few people actually do so, because there are a number of tangible benefits
to be gained by writing and using accessors that follow a simple design
pattern. The pattern is pervasive through all of Cocoa, and using it in
your own code makes a number of things Just Work - key-value coding
observing, serialization, Cocoa bindings, etc.

Now, these benefits seem to be merits of Cocoa, not of Objective-C per
se. A good Perl class hierarchy written for some purpose could do that
for its clients too.
In short, if Perl's approach has a weakness, I don't think it's the lack of
a stick, but rather the lack of a tasty carrot.

To stick (hehe) with the image, the carrot is there, if predictable behavior
of derived classes is tasty. But it's way out of sight.

You don't see the immediately gain in painfully going through accessors
when (for instance) a hash slice is more natural (and more perlish).
If you don't know the rules of the OO game, you're bound to say: It's my
class (right), it's my code (also right), it's my method (wrong!). It's
also a method of any class that inherits from yours, and you must
*consider* that, it makes a difference in non-obvious ways. It seems
to me that Perl OO requires more of that kind of consideration than
other OO languages.

Sure, the freedom we gain in Perl is lovely. The way Exporter.pm uses
inheritance to its advantage without being otherwise OO at all is a
nice example.

Sorry for explaining in so much detail what must mostly be clear to you.

Anno
 
S

Sherm Pendley

Anno said:
also a method of any class that inherits from yours, and you must
*consider* that, it makes a difference in non-obvious ways. It seems
to me that Perl OO requires more of that kind of consideration than
other OO languages.

I agree. I certainly wouldn't suggest Perl as a language for teaching OO
concepts. In fact I don't think I'd suggest Perl as any sort of teaching
language at all - it's far too forgiving to be useful for that.

I simply meant to counter the claim made by many Python advocates, that it's
utterly impossible to write good OO code in Perl, because it lacks access
modifiers. That's a straw-man argument with no basis in logic. Not only is
it possible write good OO code without them, it's also possible to declare
everything as "public" and write sloppy OO in languages that do have them.

sherm--
 
A

A.M. Kuchling

I simply meant to counter the claim made by many Python advocates, that it's
utterly impossible to write good OO code in Perl, because it lacks access
modifiers.

I doubt anyone is making that claim, but Python doesn't have access
modifiers either.

--amk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top