Advantages of Python over C++

--Originally published at Luis Santana's Blog

Python is an object oriented script language while C++ is an object oriented compiling language. But they are very different languages and  their differences among them aren’t really advantegous.

As Murphy said:

  • Memory management: C++ doesn’t have garbage collection, and encourages use of raw pointers to manage and access memory. It differentiates between heap and stack, and it requires you to attend to values versus references. C++ requires much more attention to bookkeeping and storage details, and while it allows you very fine control, it’s often just not necessary.
  • Types: C++ types are explicitly declared, bound to names, checked at compile time, and strict until they’re not. Python’s types are bound to values, checked at run time, and are not so easily subverted. Python’s types are also an order of magnitude simpler. The safety and the simplicity and the lack of declarations help a lot of people move faster. Speaking of…
  • Language complexity: C++ is a beast of a language. The spec is 775 pages of language legalese, and even the best C++ developers I’ve known can be caught up short by unintended consequences in complex (or not so complex) code. Python is much simpler, which leads to faster development and less mental overhead.
  • Interpreted vs compiled (implementation): C++ is almost always explicitly compiled. Python is not (generally). It’s common practice to develop in the interpreter in Python, which is great for rapid testing and exploration. C++ developers almost never do this, gdb notwithstanding.

C++ tries to give you every language feature under the sun (circa 1990, at least) while at the same time never (forcibly) abstracting anything away that could potentially affect performance.

Python tries to give you only one or a few ways to do things, and those ways are designed to be simple, even at the cost

some language power or running efficiency.

In many cases, Python’s philosophy is an advantage because it lets you get most tasks done more easily and more quickly with less mental overhead.