Okay, I know that Python is a programming language (it comes with some Linux installs), but what are its stats? I mean, how efficient is its build? How much larger or smaller are the programs than C++? How much faster are the programs than those created by C++?

What are python's strong points and weak points? I just wanna know before I start using it, so I have more of an idea of what I'm getting myself into.

Recommended Answers

All 7 Replies

The major difference between C++ and Python is that Python compiles source code to byte code and then interprets the byte code. There are programs that combine the byte code with the interpreter and package to an executable for distribution. More and more computers have Python already installed, so you can just distribute your Python programs as source code, or more secretive byte code.

Some programs can run slower than the corresponding C++ program, but there are ways around this with modules written in C or C++, or just in time compilers similar to Java. Python has an easy way to handle modules.

Python is a high level language, very powerful, very modern, with a wealth of builtin classes and functions/methods. For instance, most of the STL containers that you are familiar with in C++ are builtin. If its not built into the language it is supplied as modules. Many modules are written in C or C++, transparent to you. Python has a very efficient memory manager builtin, so the notorious memory leaks of C++ are gone!

The major advantage of Python over C++ is its rapid development time for programs. On the average, programs are developed up to 10 times faster. Python code is easy to write, read, test and maintain. One of the reasons that Google uses Python extensively. Microsoft does not, and seems to lack behind most of the time. In my opinion, knowing C++ and Python is the best of both worlds.

Check out the "Starting Python" thread, or some of the Python code snippets to get a feel for Python!

Good insight by Ene here! One additional comment, Python is object oriented, but unlike Java, the use of OOP is optional.

The major problem with Python is its relative newness. The entrenched computer-science teaching staff of many institutes of higher learning is used to teaching C++ or Java, not-so-new languages that can inflict much pain on the poor students, making the teacher the master (mild sarcasm here)!

God forbid, teaching Python might lead to fun, experimentation and discovery. Worst of all, the teacher might have to learn something new. Why waste all those boring class notes, that have served so well all those years?

Sounds like I am just a grumpy old man! Well, it is not quite as bad! Python has been accepted by much of the science teaching staff, because it is application oriented. There are a large number of scientific modules available for a free download.

Knowing both Python and C++ is indeed ideal! Python for exploring concepts, and C++ for the few times when execution speed is of utmost importance.

I've done some of each, and I'm loving learning Python. It cleans up the thought processes considerably.

Jeff

I have used Python and I am learning C++. Programs that are just a few lines of code in Python are nightmares in C++, like splitting sentence into words and loading them into array of strings dynamically.

Let's not forget the Python allows Functional (ala Lisp) and Meta Programming. Just a different approach (higher level) to pogramming.

Do we need that?
Once you play with it you'll miss it!

I have used Python and I am learning C++. Programs that are just a few lines of code in Python are nightmares in C++, like splitting sentence into words and loading them into array of strings dynamically.

Don't forget reusable code ... create a string object in C++ with all of the methods of Python strings, and then save it in a safe place.

#include is your friend!

Jeff

Thanks Jeff! How would you do this tiny project in C++?

# split a string into its words
str1 = 'You never find a missing item until you replace it'
wordList = str1.split()
for word in wordList:
    print word

I have been following Bumsfeld's tribulations with C++!

Mais oui, you can do it in C++, but it will be a mess of very ugly code!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.