Hmmm Should I Quit C++ To Learn Python?


Tastie

Still Fresh
Joined
Sep 24, 2008
Messages
11
the title doesnt exactly explain all.
i've been wanting to learn to program for quite a while, because i love video games and want to start making them. i bought a book on C++ (C++ Without Fear) and have been reading it for a little over a month. I'm about halfway through it, and i really do understand all the content it's gone over, but after lurking on these forums i just discovered python(and how fun it looks)

so basically im asking,

even if im understanding C++ without difficulty, would it be better to switch to python? since i've pre-ordered a pandora unit and would love to develop for it, python looks to be way easier for programming on the pandora(correct me if im wrong)

or should i learn python AFTER C++? that way i could do both!
 
specifically better for game development on the pandora(in terms of difficulty and results)
 
A well optimised C++ program should certainly make considerably more efficient use of the P's limited resources, than an interpreted Python program (compiled python may fare better in this regard though).

Python being higher level should probably be easier (barely touched it myself, mind), and if you aren't planning too resource intensive a game should run well enough.
 
Python is interpreted, interpreted languages are slower then compiled languages.

For game development you normally use a graphics lib/game engine such as irrlicht/crystal space. which does most of the hard work for you anyway.

personally I find python, and other higher level languages to be __more__ confusing than C/C++.
 
I have always seen phyton as kinda start into programming - Do whatever you like... I have never used phyton tho

Personally I don't like all these mainstream languages including phyton (and even C and C++) but as this is the only real option for this device for some time I have to use it if I don't want to write everything in assembler (which I like btw ;) ).

But in my opinion C++ ist still better as it is not as high level as phyton, its probably faster in many cases, there are more tutorials on it I think and you have easy access to most API (not sure about phyton).
Phytons advantage would be that you could program on your pandora , as other people said: there are interpreters

When I had to decide which language I was going to learn after Visual Basic 6 so I could go cross-plattform I decided to learn C++, I don't know much about it yet, but "it works"
I wrote my own scripting system now which dynamicly recompiles. Its similar to assembler too - everything is really low-level. But atleast that allows me to give my programs a fast framework in C++, which can be programmed directly on the pandora using my own editors.
 
Stick with C++ (or C for that matter). Python is very simple, you could pick up the basics in an afternoon with a good book (e.g. Python in a nutshell or similar) and some example code.
 
Python is much more dynamic, easy to use and powerful than C or C++ or Java. The only drawback on the pandora may be performance, but from experience I can tell you that by rewriting the few functions that take a lot of time in C (loading it with Ctypes) or in Cython gets you performance on par with java and comparable with C++.

C is useful to know, not so much C++ (which is a complete mess). If you can stand it, learn C++. You can learn python very quickly afterwards.
 
some benchmarks from http://www.mindstab.net/wordpress/archives/tag/mac
Inferno Nika Kvasir Bast GP2X
C 1.19 0.79 0.45 2.83 35.1
ObjC 1.19 0.8 2.83 43.4
C++ 1.93 1.06 1.1 4.76 50.1
Java 3.59 1.63 2.14 40.3
C# 3.69 1.87 10.5 140
Awk 32.1 27.1 30 199 2065
Perl 38.2 21 23.3 145 1280
PHP 15.1 8.89 13.4 64.9 758
Python54 38 43.8 211 1526
Lisp 10.4 5.19 36.3 2674
Python seems much slower than C++, C seems best in terms of this benchmark
 
JayFoxRox said:
I have always seen phyton as kinda start into programming - Do whatever you like... I have never used phyton tho

Personally I don't like all these mainstream languages including phyton (and even C and C++) but as this is the only real option for this device for some time I have to use it if I don't want to write everything in assembler (which I like btw ;) ).

But in my opinion C++ ist still better as it is not as high level as phyton, its probably faster in many cases, there are more tutorials on it I think and you have easy access to most API (not sure about phyton).
Phytons advantage would be that you could program on your pandora , as other people said: there are interpreters

When I had to decide which language I was going to learn after Visual Basic 6 so I could go cross-plattform I decided to learn C++, I don't know much about it yet, but "it works"
I wrote my own scripting system now which dynamicly recompiles. Its similar to assembler too - everything is really low-level. But atleast that allows me to give my programs a fast framework in C++, which can be programmed directly on the pandora using my own editors.
I also started with visual basic :) its nice
but then I moved to C, because of a course in my university's 1st semester

I tried python on my own and it really is nicer to code in, but I'd never recommend it as a first language. basically because C is much more important (historically, and it's still widely used) and you need to know what's behind a language, know how it works and code with this in mind.
C is easy enough to be your first language, little console apps are very easy to make in the first day and are sure to give the person the feeling involved in programming. and that's what's more important.

well, off the philosophic talk, stick with C++. it's a very important language, you will use it a lot in many places, and it's sure to have lots of libraries for you to work with on the pandora. python's slowness will really have to be taken into account, this is a case where python's easiness of use will not actually get paid off by the lack of performance.
 
Last edited by a moderator:
QUOTE
I prefer C++ but give Python a try, there is no one true programming language, try both and see what you prefer.


I object, asm (or binary) is the one true programming language IMHO ;) . Personally I think that if you already know C++ then it probably would be a better idea to use it in place of python due to performance. Python might be good for 2d games or using it with a wrapper, but for more complex tasks C++ is probably a better option.
 
C/C++ and Python are both very good languages... for what they are designed for.

C/C++ were designed for execution efficiency (runs fast)

Python was designed for programmer efficiancy (write programs in less time)

C was originally intended for systems programming (i.e. Operating systems, device drivers, etc.) where execution speed is everything. You can create extremely efficient code by using some less readable (harder to maintain) coding style when you need to. C++ was originally a hack to C to add OOP concepts to the language, but has improved tremendously over the years. Now C++ is intended for any type of programming, but still has it's roots in C's systems programming focus.

Python on the otherhand is all about quickly writing code and having it be easy to read and maintain. One of the Python philosophies is that you write code once, but you read it many times. Another philosophy is that modern CPUs are so fast, your code/language doesn't need to be the most efficient at runtime, so make it efficient for development. Python also works for scripts.

I'd suggest picking the language that fits your taste and target application. If you're planning to write extremely demanding 3D apps, C++ is probably the best choice. If you want to write simpler games (e.g. 80's arcade style, tetris, bejewled, etc.) you could use either and it's a metter of preference. If you want to write scripts to leverage existing command line tools, then Python would be better.
 
I'll echo what the above poster has to say. C++ will give you a lot more raw power to work with, but Python will make developing in general a little easier. Personally I find a lot of the tasks for C++ tedious as hell and am prone to making errors due to that, which can lead to obscure memory leaks or other fun little bugs that are notoriously hard to track down.

If you're methodical enough that C++ isn't a problem, then it's a fine language. Inevitably with Python if you write more complex games you will hit areas where Python's performance leaves something to be desired, and you'll have to work around this somehow. Again, personally I just see that as a challenge but not everyone is happy with having to do that.

Also, working with Python for games for a short while now I notice that the libraries available for hardware accelerated stuff like the "layers of sprites" concept which works well for any engine that doesn't have a lot of very specifically ordered overlap of graphics going on. The libraries are in part part of the strength of Python to write simple games quickly and easily, but I'm looking at creating my own vertex lists for Pyglet now cause the available methods aren't suitable for my needs, thus taking some of the speed out of development.

TL;DR version: YMMV

EDIT: Knowing both is probably an advantage though. Python is very popular for extending non Python programs in areas that aren't bottlenecks in terms of speed of execution.
 
Opinions on this seem pretty generalized; it depends on what you as a programmer feel comfortable with, what you are writing, and how you are writing it. There are no hard and fast rules for what is good for what. If I were you I'd try doing things and both and think about what you'd do when writing a game, and how it'd differ between the two.

And you shouldn't have to "quit" a language - you can even do a game using C++ and Python. I'm sure many games do (or other languages).
 
Tastie said:
even if im understanding C++ without difficulty, would it be better to switch to python? since i've pre-ordered a pandora unit and would love to develop for it, python looks to be way easier for programming on the pandora(correct me if im wrong)
Depends on what you're trying to do.

If you're doing a simple side-scroller or 2D tile based rendering type game, Python may (magic word there...) get the task done. Frozen Bubble is a good example of the type of game one can conceivably do with it. It won't be optimal, and you'll have issues wringing performance out of your code in places.

If you're interested in doing "fancy" things even with 2D titles or you're gunning for 3D, you're not going to have enough muscle to accomplish what you'd like to do without resorting to C/C++ on the Pandora. There's not enough CPU muscle to accomplish the same things you can do with a modern desktop using Python. Mostly because it's interpreted.

Keep in mind, "easier" is a relative concept. I know quite a few programming languages and have coded in Python, Tcl/Tk, Perl, Java, C/C++ and a few others. You can bang out code in Python easier than in C++, yes. But can you make the game you write PLAYABLE in the language you choose? With some games, Python will require more effort than the C++ code will because you have to be more clever doing the Python code where it'll play to speed.
 
Last edited by a moderator:
Svartalf's comments really struck home for me. I was debating this topic as well, for basically the same reasons. However, I plan on being able to manage the layers in 2D graphics, and a rather intense event-based AI system. The best option was C/C++. :)
 
Svartalf said:
If you're interested in doing "fancy" things even with 2D titles or you're gunning for 3D, you're not going to have enough muscle to accomplish what you'd like to do without resorting to C/C++ on the Pandora. There's not enough CPU muscle to accomplish the same things you can do with a modern desktop using Python. Mostly because it's interpreted.
Is this true even when you let C do most of the CPU intensive stuff by using pygame or pyglet or something like that?
 
Last edited by a moderator:
I keep telling people that I've successfully used that model for scientific apps. I had about 2% C code, most of it Cython http://cython.org/. The rest was python and the interface and graphics were using Qt4. It was supposed to replace an old C++ and Qt3 app and mine actually performed better (probably because of qt4) and had less than a sixth of the LOC.

The other choice for easily writing software is D, which has the performance of C/C++, but has garbage collection and a few other productivity enhancers (like insanely fast compilation).
 
Back
Top