Is Python overhyped (just like Java)?
Stuart D. Gathman
stuart at bmsi.com
Sun Mar 30 21:33:13 CEST 2003
On Sat, 29 Mar 2003 16:38:09 -0500, Ajay na wrote:
> Can some-one please explain why one would want to use Python? What is
> wrong with C++?
1) no "safe" mode with GC, where memory overwrites, leaks, and
corruption are impossible.
2) Compiler is slow - even on 2.6Ghz Xeon. Using header caching
compilers is complex. Extensive template use makes compiler slow - but
they are essential to make C++ programming as "safe" as possible.
3) No compiler has a completely satisfactory implementation of
templates - especially the linking problem.
> Nope...I'm not trolling...I want someone to give a solid and intelligent
> argument about why I should switch from C++ to Python!
You shouldn't! I use C++, Java, *and* Python extensively. Python is
hands down the fastest programming time, has fast startup from the
commandline (so is good for scripts), and C-python is parsimonious with
memory thanks to reference counting GC. The syntax is extremely clear and
compact. It is much faster than tcl or sh, but slower than interpreted
Java. It is similar in speed to Perl - but you can actually understand
the code a month later.
>From Python, often used code migrates to Java for a more efficient
execution environment. Like Python, Java doesn't care what class an
Object is, only what interface it implements. Unlike Python, Java
documents expected and implemented interfaces, checking them at compile
time where possible, and at runtime otherwise. We don't usually use JIT
with Java. JIT eats tons of memory. However, for CPU intensive long
running servers, Java with JIT can match C as long as there is plenty of
memory. Things like internet nameservers, mail transfer agents, should be
written in Java to avoid the buffer overflow and double free security
problems that plague C/C++ versions. Java syntax is not as nice as
Python, but is simpler than C/C++. The special syntax for primitives
is annoying. I wish Java had python-like syntax while keeping Java
semantics. Python scripts can be used directly with Java thanks to the
Finally, for pieces where fastest possible startup and/or raw runtime
speed are important, you can't beat C/C++. This speed can be obtained
with fairly highlevel and maintainable code thanks to the wonderful STL.
Best of all, when a command line or socket interface is too slow, C/C++
code can be called from Python and Java via JNI and Python CAPI (assuming the
C code has been thoroughly tested for memory problems and buffer
In short, Python can call C/C++. Jython can call Java. Java can call
Jython. Java can call C/C++. C/C++ can call Java. C/C++ can call
Python. Plus, all three can invoke each other via command line and
network. All three support exceptions. All but C/C++ have standard GC,
and C/C++ can interoperate with Python/Java GC when talking to those
virtual machines. All have different strengths and weaknesses. Use all three.
Stuart D. Gathman <stuart at bmsi.com>
Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154
"Confutatis maledictis, flamis acribus addictis" - background song for
a Microsoft sponsored "Where do you want to go from here?" commercial.
More information about the Python-list