Perl and Python (Re: [prog] Re: [Techtalk] How to write web proxy in Python?)

Mary mary-linuxchix at puzzling.org
Fri Jan 10 10:13:58 EST 2003


On Thu, Jan 09, 2003, Nancy Ging wrote:
> I have a question--what is the difference, in terms of how and when
> you would use each--between python and perl? I've done lots of perl
> programming but never taken a look at python. Is there a good reason
> to do so?

Perl was originally designed (I believe) as a kind of killer shell
scripting language. Hence it's really good at a lot of things you would
need a shell script for - string manipulation in particular, and taking
the output of a program, and manipulating it. (Of course, there are so
many modules for it now you can do practically do anything with it.)

Python was designed as a dynamically typed teaching language. Hence, its
style of object orientation the style of subroutines is much more like
non-scripting languages: Java and C++ in particular - except that it's
dynamically typed. (Really dynamically typed - you can rewrite
inheritence trees *at runtime* although that doesn't mean you *should*.)

So if you like object oriented programming, Python is a very fast
prototyping language (many fewer lines than Java or C++ in general I
believe, although I haven't sat down with a really good Java, C++ and
Python programmer to test this). If you aren't writing something
computationally intensive, Python is also a good choice for a final
development language, and you can write bits of it in C if you need to
them quickly.

Python also has some functions that are LISP like (it has map, lambda,
filter, and reduce, although doesn't Perl have some or all?) and many
LISP programmers, including Peter Norvig, have adopted Python as "not
LISP, but good enough".

If you want to do string manipulation, or glue to output of different
programs together, I would tend to use Perl.

But I found coming to Perl from other languages harder than coming to
Python, because Perl is almost unique in certain characteristics (its
scoping is global unless you "use strict;" isn't it? and subroutines
take a single list rather than named arguments, and I had trouble with
references, because of the function of $ both as a dereferencer and
coercing to scalar).

I'm by no means a Perl proficient though, so someone proficient in both
Perl and Python would make a better job of the comparison.

-Mary



More information about the Programming mailing list