C++ or Python

Dan Stromberg dstromberglists at gmail.com
Sun Jun 29 05:54:53 CEST 2008


On Fri, 27 Jun 2008 15:22:26 -0700, Kurda Yon wrote:

> I would like to know what are advantages of Python in comparison with C
> ++? In which cases and why Python can be a better tool than C++?
> 
> Thank you!

Python's automatic tracebacks on errors facilitate debugging very nicely.

Python doesn't have much in the way of stray pointer references or out of 
bounds array references (you'd pretty much have to use a poorly-written 
extension module to get them), making development in and maintenance of 
python code much less expensive in human time.

Python has garbage collection, which means you don't need to worry much 
about memory leaks.

Python isn't just another curly brace language - it reads more like the 
pseudocode you'd see scribbled on a white board, perhaps than any other 
language.

Python's a very dynamic language - so there are things where C++ would 
catch errors for you that Python wouldn't.  However, this also means that 
you don't spend time declaring variables over and over in Python.  Also, 
things like passing a method as a function parameter is a no-brainer 
(requires extra syntax in java because of the cautious type system - not 
sure about C++).  Python's dynamicity also means that you don't need a 
clunky mechanism like templates or have to use inheritance just to get 
type parameters.

In python, everything is an object.  Not everything has methods, but 
everything can be stuck into a variable - modules, pieces of code, 
whatever.  Just try to stick an arbitrary header file's expansion into a 
variable in C++.




More information about the Python-list mailing list