Python vs C for a mail server

Alex Martelli aleax at mail.comcast.net
Sat Jan 28 11:58:51 EST 2006


Jens Theisen <jth01 at arcor.de> wrote:
   ...
> Please don't be offended, but if anyone could make a point of how Python's
> disadvantages in these regards could be alleviated, I'd be very  
> interested.

<http://www.artima.com/weblogs/viewpost.jsp?thread=4639>
<http://www.mindview.net/WebLog/log-0025>

Since Robert Martin and Bruce Eckel (the authors of the two documents
linked above) are both acknowledged gurus of statically typechecked
languages such as C++, the convergence of their thinking and experience
indicated by those documents is interesting.

Tools such as pychecker, pylint, etc, are also considered by some to be
a useful backstop, but unit-tests are the real answer.

The "but without declaration it can't be self-documenting" issue is a
red herring.  Reading, e.g.:

int zappolop(int frep) { ...

gives me no _useful_ "self-documenting" information about the role and
meaning of frep, or zappolop's result.  The code's author must obviously
add a little comment here to clarify -- and in that little comment,
adding the information about type, if at all relevant, is an obvious
task.

At Google, we collectively have rather a lot of experience in these
issues, since we use three general-purpose languages: Python, Java, C++.
In this mix, the role of C++ is essentially that of allowing the
programmer to have complete control on memory allocation issues: the
only widespread modern language to do that, since all others, including
both Java and Python, have garbage-collection.  In the internal style
guide for C++, we forbid the use of so-called ``smart'' pointers which
would basically amount to a hacked-up garbage collection system (which
can never be as solid and thorough as those built into the virtual
machines used in Java or Python -- a GC system that's thread-safe is a
nightmare to build and debug based only on those "smart pointers", for
example, and if you start locking and mutexing all over the place for
that purpose you'll soon see performance plummet...): if you want
garbage collection you use a garbage-collected language -- the choice of
C++ for a component implies that you need complete control of memory
issues for that component, therefore choosing C++ and ``too smart for
their own good'' pointers would be mutually contradictory.  Our style
guides for all languages also impose using unit-tests, code reviews, and
standard formats for internal documentation, from naming of variables,
functions and classes to structure and form of comments.  As a result,
quality and reliability are remarkably consistent and uniform.

We could say that Python is Google's "secret weapon", except it's not so
very secret, since, in order to attract and hire Python experts, we do
of course need to let it be known that Python's important to us;-).  In
a sense, I guess, we are fortunate that our competitors still appear not
to be fully aware of this -- it gives us a better chance to hire Python
luminaries and maintain a productivity edge;-).


Alex



More information about the Python-list mailing list