What is Python good for?

Alex Martelli aleax at aleax.it
Wed Sep 12 16:44:35 CEST 2001

"Steve" <stevesusenet at yahoo.com> wrote in message
news:6f8cb8c9.0109120541.132432d4 at posting.google.com...
> Java is great for server side programming.  Perl is easy, and has a
> lot of built in features for text processing.  Visual Basic makes
> generating windows client app interfaces very fast.

If you think Perl is easy to master, then you're a very unusual
sort of person.  Python *IS* easy -- incredibly easy for either
a programming beginner to start with, or a programming expert
to master.  It works regularly, without surprises, without
mysterious magical "helpful" and "convenient" tricks, context
dependence, irregularities, and so on.  I had a better grasp of
Python in about a year from starting to use it (an essentially
total grasp), than of Perl after many years (I could basically
do things, but regularly got bitten by some yet-unfamiliar
"convenient" exception, context-dependence, irregularity, &c).

Apart from this little issue (and the related facility of
maintenance that Python offers, while Perl makes it easy
indeed to write unmaintainable, unreadable programs), Perl
and Python are basically equivalent in most respects that
count.  What Perl has "built-in", Python tends to have as
a part of its standard, included library (making the language
simpler, but with the same power).  Both have zillions of
extension modules available (Perl has more, and the CPAN
structures makes them easy to find and get; Python has a
few that are non-pareil if you need them, such as Numeric
if you do numeric computations, and makes it easy to add
your own, e.g. by wrapping any existing library).

Python has a splendid, 100% pure Java implementation called
Jython, which lets you use Python for *anything* you can
use Java for, seamlessly.  Bruce Eckel has a good chapter
on that in his coming book "Thinking in Patterns", based
on Java, which you can download freely from his site (as
you can for all of his other current best-selling books,
I believe).  If you need or want to deploy on a JVM, e.g.
to use something that's best available in/for Java, Jython
lets you do it with higher productivity.

> What is Python's major strength?  What benefit will someone have by
> taking the time to learn it?

Productivity.  Lutz Prechelt made a study of productivity
(quality of delivered solutions, performance issues, and
amount of work to reach the solution) covering C, C++,
Java, Perl, Python, Rexx and Tcl.  Perl and Python by far
dominated (with statistically undistinguishable values)
in terms of programmer productivity, and the resulting
programs, while not as fast as the best C/C++ ones, were
easily faster than those in Java (not to mention Rexx and
Tcl, whose performance was worst).

> Where does Python fall short?

Speed.  If you need to get 100% of a CPU's potential,
you will *NOT* be able to do that in pure Python (unless
all the real bottlenecks are in C-coded Python *extensions*,
e.g. if all the real CPU-intensive work your program is
doing is in such stuff as numerical computation, image
processing, database work, networking, XML processing, 3D,
multi-precision arithmetic, and a zillion other fields
for which C-coded Python extensions are available).  For
many applications that may not be a problem -- if you
find pure-Java's performance acceptable, pure-Python's
will probably also be, depending on what underlying
C-coded stuff is actually running in either case.  But
if your application is heavily CPU-bound in "novel"
ways (i.e., in ways for which nobody has yet written a
C-coded Python extension), you may have to recode some
small hot-spot parts of your Python solution as Python
extensions, just like you'd have to do with Java and JNI
(it's somewhat easier for Python, but it's still C level
coding, unless you're fortunate enough to be able to
use automatic wrapper generators over existing C/C++
libraries and get the speed without the sweat -- but,
no matter how good tools such as SWIG are, in some cases
you'll still need to hand-tune C code if you do need
all-out, no-compromise, 100% hardware performance).


More information about the Python-list mailing list