Python versus Perl ?
Kartic
removethis.kartic.krishnamurthy at gmail.com
Sun Feb 6 09:26:37 EST 2005
surfunbear at yahoo.com 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
More information about the Python-list
mailing list