Python versus Perl ?

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

Reinhold Birkenfeld

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.

"Better than Perl" is a very general statement. In my personal opinion,
this is true for every project being larger than one file of ~200 LOC.
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 ?

There are the Python Package Index (PyPI), the Vaults of Parnassus, and
when you don't find a needed package there, just come and ask here;
almost always a decent solution is found.

A thing similar to CPAN is being worked on by various people, though I
don't know when it will become mature.
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.

Python has regular expressions much like Perl. The only difference is
that Perl carries syntactic support for them, while in Python regular
expressions are ordinary objects with methods etc.
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 ?

There is the Perl 6 movement, but when you read some of the docs at
http://dev.perl.org, you will come to the conclusion that

- Perl 6 lies at least 3-5 years in the future and
- it will be a huge mess. Someone here once said "Perl 6 is the ultimate
failure of Perl's philosophy". There may be split views about this...
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.

Same goes with Python; it is installed per default on most modern
Unices. Windows is a completely different chapter, however, Perl isn't
more widespread 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 ?

It doesn't harm, of course. Recent statistics about programmers'
salaries indicate, however, that Python ranks top (I somehow lost the URL).
If Python is better than Perl, I'm curious how really significant
those advantages are ?

Try to decide yourself. The Python tutorial and website are your friends.

Reinhold
 
K

Kartic

(e-mail address removed) said the following on 2/6/2005 8:19 AM:
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.

Python is great for pattern matching using the re module. If you are
talking about the ~= operator, that is not available in Python but you
can your favorite Regexp matches/searches/replacements using the re
module. And actually I like Python re sub better as it has a clean
syntax. One can provide a replacement function to the sub method where
one can manipulate the matched groups. Please see
http://www.amk.ca/python/howto/regex/ for more info.

Automated testing - One of the best languages to create automated test
cases and still remember after a few months what your test cases... that
is how clean Python syntax is. And you have not specified exactly what
kind of automation you do. I code test cases for Win32 as well as
testing data exchange over FTP and Telnet.

I know a lot of toy and serious parsers written in Python. Heck, there
is even a Python implementation in Python. Text Processing is simply
superb, combined the the re module. I am not too qualified to talk about
text processing but lets say life is a breeze! You can read about Python
Text Processing at http://gnosis.cx/TPiP/ - this is a whole book
dedicated to text processing in Python. Also see
http://www.python.org/moin/LanguageParsing

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.

While, AFAIK, there is no CPANish library, Python comes with "batteries"
included, i.e., almost everything you would need to churn out the
programs you need. For everything else, there are independent projects.
But take a look at the Vault of Parnassus for a BIG collection of Python
modules/projects/applications.

Python has a DBI compliant API which means all compliant modules support
the same syntax. And Python has modules supports all major databases.
See http://www.python.org/topics/database/
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 ?

Well, Perl's lack of a decent OO approach is one reason I converted to
Python. Another was Perl's syntax; I could not read my own code unless I
had put copious amounts of comments. Python enforces clean coding using
indentation levels that associates blocks of code; so no need of a {} or
BEGIN/END and you will be amazed at how indentation, which IMHO, any
programmer should anyway practice for readability, can make the code
easy to comprehend.
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


That actually depends on the OS. I believe Sun OS comes with Perl and
that is because of the historic use of Perl for sys admin work. Redhat 8
onwards comes with Python installed because Redhat's install process is
written in Python. Windows comes with neither. And for your sysadmins,
installing Python should not be difficult at all. As long as you
identify the need and tell them that is what they must do for your
accomplish your tasks efficiently, I don't see this a stumbling block at
all!
> available. It's usually 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 ?

I don't see the correlation between the number of jobs available and
fashion-statement of a language, if that is what you are insinuating. My
job does not require me to know Python, but I use it and effectively.
So, how does one account for that? And since you already have a job and
are considering using Python for your current job, it should not matter
to you. Moreover you increase your marketability by learning both Perl
and Python...you have access to 108 + 17 jobs :)

True, there are a few Python "shops" but there are many jobs that ask
for knowledge of Python, especially testing positions. The few Python
shops are places you will die to work for - like Google may be?

Other aspects that support adoption of Python are consistent syntax,
great OO, code maintainability and short development time (proportional
to the complexity of the design).

Good that you asked this question as part of due diligence. These are
the factors I can point out. If I have missed something or misquoted,
gurus out there can correct me.

Hope that helped!
-Kartic
 
R

Roy Smith

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

moma

Reinhold said:
"Better than Perl" is a very general statement. In my personal opinion,
this is true for every project being larger than one file of ~200 LOC.




There are the Python Package Index (PyPI), the Vaults of Parnassus, and
when you don't find a needed package there, just come and ask here;
almost always a decent solution is found.

A thing similar to CPAN is being worked on by various people, though I
don't know when it will become mature.




Python has regular expressions much like Perl. The only difference is
that Perl carries syntactic support for them, while in Python regular
expressions are ordinary objects with methods etc.




There is the Perl 6 movement, but when you read some of the docs at
http://dev.perl.org, you will come to the conclusion that

- Perl 6 lies at least 3-5 years in the future and
- it will be a huge mess. Someone here once said "Perl 6 is the ultimate
failure of Perl's philosophy". There may be split views about this...




Same goes with Python; it is installed per default on most modern
Unices. Windows is a completely different chapter, however, Perl isn't
more widespread there.




It doesn't harm, of course. Recent statistics about programmers'
salaries indicate, however, that Python ranks top (I somehow lost the URL).




Try to decide yourself. The Python tutorial and website are your friends.
Reinhold


I like Ruby because it inherits so many (best) features from Python and
Perl ;) Someday all these languages will compile to a common
intermediate representation (ref. YAML: http://yaml.kwiki.org ||
http://yaml.org )

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/79533

http://www.cs.washington.edu/homes/kd/courses/pythonruby.pdf

http://www.ntecs.de/old-hp/s-direktnet/rb/download_ruby.html

http://www.ruby-lang.org/en/


// moma
 
A

Alex Martelli

Reinhold Birkenfeld said:
Python has regular expressions much like Perl. The only difference is
that Perl carries syntactic support for them, while in Python regular
expressions are ordinary objects with methods etc.

In many ways, Python's modularity is advantageous here. However, since
(I believe) about Perl 5.2 or so, Perl's regular expressions aren't --
they're more powerful than regular expressions, because you can embed
arbitrary Perl code in them as part of the matching process. Python's
regular expressions are very close to those of Perl 5.X for some X<2 (I
think it was 5.2 where the code-embedding trick was introduced, but
that's something of a guess on my part).
It doesn't harm, of course. Recent statistics about programmers'
salaries indicate, however, that Python ranks top (I somehow lost the URL).

"Software Development" magazine has run such polls for years, and the
fact that Pythonistas' salaries are at the top has been true since the
first such poll -- not a huge difference, but statistically significant.
What this finding _means_ is, of course, somewhat of a mystery
(correlation isn't causation), as is, of course, the OP's less formal
observation about job postings.


Alex
 
C

Courageous

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

The main advantage is Python's cleanliness. In Perl, there are so
many different ways of writing a thing, that to be adept in perl,
you have to know them all, otherwise you won't be able to read another
person's code.

Python and Perl accomplish similar things, but have strikingly different
design philosophies. Perl's design philosophy is the kitchen sink: throw
it all in. Python's is, "let's keep this simple." We add things carefully,
and with great deliberation, or not at all.

As a consequence, Python is far easier to learn than Perl.

This has non-trivial consequences on your enterprise operations.

For example, getting new engineers up to speed on the old code base is
a great deal easier.

C//
 
J

Jorgen Grahn

On 6 Feb 2005 05:19:09 -0800 said:
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.

I could go on and on, but this essay by Eric Raymond says it better:

http://www.linuxjournal.com/article/3882
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 is in most Linux installations ... but it's much more rare than perl
elsewhere. Yes, this is a reason to write smaller text-processing and
automation hacks in perl.

/Jorgen
 
S

snacktime

I just recently picked up Python after using perl almost exclusively
for the last 8 years, and the above mentioned article by Eric Raymond
echos my feelings almost exactly.

The one drawback coming from the perl world is that you don't have as
many options when it comes stuff like application frameworks, and some
of the third party modules just aren't as well tested not having the
huge user base that perl does. I end up spending a bit more time
searching for different libraries than I did in perl, but beyond that
I think python is better overall.

Chris
 
E

EP

(e-mail address removed) asked
3. Perl is installed on our system and a lot 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 ?

Python is trivial to install on one's workstation or PC, if it isn't already there. Getting Python on the company's servers can require some IT latitude or buy-in.

<opinion>

I've begun to view the availability of Python on company servers as a measure of an IT organization's fitness.

Perl was (probably) the right language at the right time at least for cgi work and text processing in the early days of the web, when there was a sudden increase in the need for such work. And Perl "works", especially as you become familiar with it and some of the non-obvious ways it works. Learning Perl is an investment and many folks becomes Perl people - why would you switch from anything you've put that much time into?

And so a vast number of people and orgnizations remain in the cave, unwilling to risk going outside, unwilling to believe life could be better out there in the unknown. Congrats for being the rare person who takes a look. (That strange feeling you may get is from something we call "sunshine" and, on balance, I think you'll find it is a very nice thing.)

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

I'd say the advantages are significant if you develop anything complex, or like to think about the software you develop in clean abstractions. I'd say knowing Python probably does not lead to a higher salary, but that the software engineers attracted to Python tend to be the cream of the crop and are worth more money.


[Disclaimer: Python also attracts some who are not cream of the crop software engineers but rather see things - applications, large or small - that ought to be done, and are looking for the most efficient way of getting there.. Anyone can write some Python succssfully, but not everyone is capable of contributing to PyPy. Python is a great tool for each.]

</opinon>

Recommendation: Python requires little investment. Play in it. Read (briefly) about the aspects that seem interesting. Try writing a small progam in it. There are very very few cases where anyone is going to require you to use Python; it's a personal decision, and the people that use Python do so because they want to, not because someone required them to.


cheers/
 
R

Roy Smith

EP said:
There are very very few cases where anyone is going to require
you to use Python

Conversely, it pays to understand when you are likely to be permitted to
use it (or any new technology), and when you are likely to be forbidden.

Companies are generally the most conservative about "customer-facing"
projects. Something that's going to be shipped to a customer, or used
directly by a customer, is not a good candidate to try and the the PHB to
approve using something new.

The next step down the line is something which is going to be used by many
people within your own organization. If you write a tool in language X and
want it to get adopted as a tool that everybody uses, don't be too
surprised if the answer is, "Yeah, but who's going to maintain it, nobody
but you knows X".

The easiest way to sneak a new technology in the door is on a project where
nobody else has to use the technology directly, in other words, a tool you
write to help you get your own work done. When the boss notices that
you're getting your stuff done in half the time most of the other group
spends doing it, and you tell him it's because you're using X and everybody
else is using Y, it's like waving dollar signs in front of his face.
 
A

Alex Martelli

snacktime said:
The one drawback coming from the perl world is that you don't have as
many options when it comes stuff like application frameworks, and some

URK -- _my_ feeling is that we have entirely *too many* options for
stuff like web application frameworks, GUI toolkits, XML processing, ...


Alex
 
D

Dan Perl

Alex Martelli said:
URK -- _my_ feeling is that we have entirely *too many* options for
stuff like web application frameworks, GUI toolkits, XML processing, ...

Alex's comment resonates so much with me right now that I propose it for
QOTW.
 
C

Caleb Hattingh

Hi Surfunbear

I don't know about the stuff regarding jobs, resumes, etc, but I will tell
you the same thing I tell everyone I meet regarding python:

Set aside a morning, and work through the python tutorial that comes with
the documentation. People like me are going to tell you this and that,
perhaps try to convince of our particular world-view, and so on.

By the end of the tutorial (more likely at halfway) you will probably know
whether this is worth pursuing or not. Oh, and do this before you invest
too much time in Perl :)

Keep well
Caleb
 
P

Peter Maas

His survey of programming languages in "The Art of Unix Programming",
available at
http://www.catb.org/~esr/writings/taoup/html/languageschapter.html , is
interesting (and biased). Raymond evaluates C, C++, Shell, Perl, Tcl,
Python, Java, and Emacs Lisp.

One part of this survey strikes me:

esr> In fact it's generally thought to be the least efficient and
esr> slowest of the major scripting languages, a price it [Python]
esr> pays for runtime type polymorphism.

If I assume Perl, Python, Ruby, Tcl and PHP to be major scripting
languages some benchmarks (http://dada.perl.it/shootout and
http://shootout.alioth.debian.org) show that Python is probably the
fastest among these (Perl is 25% faster at regex matching).
 
F

Fredrik Lundh

m said:
speedwise, i think perl is faster than python and python performed the slowest as shown in
http://www.flat222.org/mac/bench/

if you use Python mostly to write empty loops, your programming license
should be revoked. the benchmark author seems to have realized that, as
can be seen from the "it's dead" paragraph at the top of the page, which
makes me wonder why you posted this link...

</F>
 
M

m

Fredrik said:
if you use Python mostly to write empty loops, your programming license
should be revoked. the benchmark author seems to have realized that, as
can be seen from the "it's dead" paragraph at the top of the page, which
makes me wonder why you posted this link...

</F>

i was trying to decide whether i needed perl or python for some work
that i had to get done and was seeing which was faster. and came across
this link which i tht was pertinent. is python as fast as perl for the
nonempty loops that the author wrote?
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top