C++ and Python

Started by
6 comments, last by MrRage 17 years, 1 month ago
For what reasons a C++ programmer would need to learn Python. I mean is it just syntactical differences, or are there other possible benefits.
[ my blog ]
Advertisement
Unlike C# and Java, both of which are attempts to make some kind of "easier C++" for increased programmer productivity, Python actually succeeds at making a language that's easier to write in. And it does it without treating the programmers as idiots too. All it requires is a few days of getting used to.
Quote:For what reasons a C++ programmer would need to learn Python. I mean is it just syntactical differences, or are there other possible benefits.


It's a completely different language.

Reasons for using python:

- You want dynamic typing.

- You want automatic memory management.

- You want built-in bignums in your language.

- You want to pass around functions like first-class objects.

- You want a (limited) lambda construct.

- You want a simple way to write generators and coroutines.

- You like list comprehensions.

- You like the convenience of an interactive interpreter.

- You want to use introspection in your code.

- You like writing less rather than more code to get the job done.

- ...
Its like asking why an assembler programmer would want to learn C.
Quote:Original post by Anonymous Poster
Quote:For what reasons a C++ programmer would need to learn Python. I mean is it just syntactical differences, or are there other possible benefits.


It's a completely different language.

Reasons for using python:

- You want dynamic typing.

- You want automatic memory management.

- You want built-in bignums in your language.

- You want to pass around functions like first-class objects.

- You want a (limited) lambda construct.

- You want a simple way to write generators and coroutines.

- You like list comprehensions.

- You like the convenience of an interactive interpreter.

- You want to use introspection in your code.

- You like writing less rather than more code to get the job done.

- ...


SOLD!
[ my blog ]
Also, if you're looking for a scripting language for your project, Python could fit the bill. Naturally, actually knowing the language helps when you want to embed it into your program. For the actual embedding, check out Boost.Python.
Just FWIW, there do exist real-world projects where Python is used to (a) "pre-cook" user-friendly data into a compact binary file to save space in the deployed version of the program (especially for mobile games); (b) generate C++ code (for example, forward-declaration headers a la <iosfwd>). I can say that with confidence because I have created both such things myself ;)
This might have been mentioned before, but you can prototype an application in Python in far less time than it would take to make the same application in C++. Sure it won’t be as fast, but speed isn’t everything.

When you prototype something in Python just ask your self, is it fast enough to do the job? If the answer is yes then great, you saved your self a lot of time and have a working product.

This topic is closed to new replies.

Advertisement