Python is just as good as C++ for real apps

Greg Weeks weeks at vitus.scs.agilent.com
Wed Jan 23 15:02:37 EST 2002


Kevin Altis (altis at semi-retired.com) wrote:
: Python is just as good as C++ for real apps

Well, since you raised the subject, if you'll bear with me for a paragraph
or two, I can perhaps say something interesting.

    In C programming, given some particular conceptual data type, you will
    often find in the code both a structure type and a pointer-to-structure
    type.  As you read the code, you will find the pointer-to-structure
    type actually being used.  The *only* need for the structure type is to
    allocate objects on the execution stack rather than on the heap.  If
    you're willing to forego that one performance optimization, you can
    dispense with the structure type (as Lisp, Java, and Python have done).

    Bjarne could not forego that one performance optimization.  (C++ had to
    be as fast as C.)  Consequently C++ has the complexity having of two
    types where conceptually only one is needed.  The language is further
    complicated by the addition of *implicit* pointer-to-structure values
    ("references").  None of this complexity is of conceptual value.  It
    exists solely to support stack allocation of mutable objects.  In other
    words, it is ugly.

So C++ has a performance optimization (stack allocation of objects) at the
cost of *CONSIDERABLE* language complexity.  (The fact that heap allocation
is left in the programmer's hands is another example of this, by the way.)

Unfortunately, new programmers (like a nephew of mine) can fail to follow
the above argument because of their belief that language constructs are
always good; so a language with more constructs is a better language.
Sigh.

Regards,
Greg



More information about the Python-list mailing list