• Advertisement
Sign in to follow this  

Python vs. C++

This topic is 4585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone! It's my first post. Ph33r. Or something. Anyway, I know this question has been asked probably a thousand times, but I don't see any real clear-cut answer to it (and I don't know IF there's a clear cut answer...) but here goes. I saw someone asking questions previously about what language and graphics library would be best to design a 2d action-rpg, and that pretty closely nails what I want to do. (although I have some ambitious plans...but I realize the road is going to be a long one to travel) I'm pretty much a complete newbie to programming, so I've been studying C++ and more recently, Python. I'm pretty sure from what I've read that if I want to use DirectX (Direct3d is what I was previously thinking), I'd have to use C++. With Python, my options would pretty much be limited to SDL. I don't really know the advantages and disadvantages of either of these setups, and I feel rather lost. Any advice, thoughts, opinions? I'd like to know what C++ does better than Python, and vice versa, as well as with SDL/DirectX. I'd like my lil' 2d action/rpg multiplayer game to have an old-school kind of look, but with enough bang in the engine to produce some pretty flashy effects with those ol' sprites. Thanks in advance to anyone who responds, angrily or not. ;)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Arydrall
Hi everyone! It's my first post. Ph33r. Or something.

Anyway, I know this question has been asked probably a thousand times, but I don't see any real clear-cut answer to it (and I don't know IF there's a clear cut answer...) but here goes.
It's not the language that makes the game, it's the algorthms that make the game.

Making things look old skool but with modern flair is the artist's job, not the programmer. The tool is the paint program, not the language.

That being said, vs. topics are always pointless. The reason two simular things exist is because they both do the job somewhat equally well(i.e. Direct3D vs. OpenGL) and which one is better is a matter of religion.

Share this post


Link to post
Share on other sites
C++ will result in faster, compiled code. However, it will obviously be more of an effort if you wish to port the program.

Python is oriented towards fast development. It will provide you more standard libraries, possibly greater portability.

As far as I'm concerned, C++ is more powerful, and more suitable for serious game development.

Share this post


Link to post
Share on other sites
One advantage of using python is that you can write your whole game in it, and later when you find out its too slow (it might not be), it shouldnt be a big deal to swap out the performance critical sections with C++ code.

Other than that I think SDL should be a good fit for a 2d rpg. Have you checked out PyGame?

Share this post


Link to post
Share on other sites
C++ is faster and lower level than Python. Python is slower but easier to program in (and therefor writing programs takes less time). C++ is the industry standard for most types of programming (excepting scripting and some types of web programming), although of course many other languages are used as well. Python is well liked by many programmers, but for whatever reason, rarely used to make full-blown commercial applications or games. There are many other differences, but those are some important ones.

Direct3D is a graphics library which lets you take full advantage of hardware acceleration for a variety of graphics tasks, such as transforming vertices, drawing triangles, lighting, and much more. Direct3D is designed to be very, very fast and powerful if used properly. It is intended for 3D, but it is very simple to ignore the 3rd dimension and use it for 2D. In addition to a large quantity of 3D functions and classes, it includes various 2D ones which together allow D3D to be used as a full-fledged 2D API, if that is what the programmer wants. SDL is a graphics library which is for 2D only (it can also be used in conjunction with OpenGL for 3D, but then you are mostly using OpenGL, not SDL). It does most of its work in software (on the CPU), instead of in hardware (on the GPU). Although some people may point out that on very old hardware this is faster, it is significantly slower on any system bought in the last five years or so, and on many bought before that.

Lots of people like and use SDL; they believe it is easier to use than Direct3D. I find Direct3D pretty easy to use, myself, but some do not. Basically, either will do what you want to some extent. Direct3D is more powerful and faster. SDL is supposedly easier to use. You should also check out OpenGL, which is like Direct3D, but cross-platform and not based on COM; you might like the coding style better.

Quote:
I'm pretty sure from what I've read that if I want to use DirectX (Direct3d is what I was previously thinking), I'd have to use C++.

Not entirely true. Managed DirectX has essentially the same capabilities as C++'s unmanaged DirectX, and is available through C# or Visual Basic .NET. However, if you are refering to Python, then I believe you are correct; I have never heard of Direct3D bindings for Python.

Quote:
Anyway, I know this question has been asked probably a thousand times, but I don't see any real clear-cut answer to it (and I don't know IF there's a clear cut answer...) but here goes.

It has been asked a thousand times, and there is no clear-cut answer. If you choose C++, I would strongly recommend Direct3D (or OpenGL) over SDL, but other than that, you will have to make your own choices.

Share this post


Link to post
Share on other sites
You guys are awesome. I wasn't expecting a reply for a day. :)

Yeah, I didn't think that there was a DirectX wrapping for Python, and I would like to apply whatever experience I gain from this towards future projects, so maybe C++ is the way to go.

Right now I'm just evaluating possibilities. I know what my goal is, I know it'll take lots and lots of time to really learn any language (I'm a slow learner)

But I appreciate your comments. Thanks. :)

Edit : Yeah, I've looked at PyGame, and I thought it was pretty nifty. Python itself is a pretty cool language setup, although I miss the compiler, to be honest. lol :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Arydrall
I saw someone asking questions previously about what language and graphics library would be best to design a 2d action-rpg, and that pretty closely nails what I want to do. (although I have some ambitious plans...but I realize the road is going to be a long one to travel)


First it is impossible to design a game in a programming language, at least very hard, but you probably just meant which was better to develop a 2d action-rpg. If you have no previous programming experience, then it is gonna take a long time before you can create a 2d rpg, so you need to create other games before, games like pong, tetris, pacman, breakout, etc. If all you want to do is have fun and create your 2d action-rpg I'ld go with Python, but if you actually is serious about this and want to develop a lot of good (and advanced) games I'ld go with C++. Anyway what you choose wont matter that much, learning a language doesn't take a long time compared to everything you need to program a 2d rpg and most of the concepts are the same in both languages.

Share this post


Link to post
Share on other sites
Yeah, that's what I'm discovering. :)

And I realize I'll have to take all the steps before I can tackle the project I *really* want to do. Tetris, here I come. ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
Quote:
I'm pretty sure from what I've read that if I want to use DirectX (Direct3d is what I was previously thinking), I'd have to use C++.
...if you are refering to Python, then I believe you are correct; I have never heard of Direct3D bindings for Python.
bzzzt! Wrong.

All you need is PyWin32, which comes with the ActiveState ActivePython distribution or can be downloaded here. This is a set of Win32 bindings including COM, and, as we all know, DirectX is exposed via a collection of COM interfaces... Of course, you need to be fairly well versed in COM to use DirectX that way, but you can find a few examples on the 'net.

My recommendation would be to develop your game in Python for the productivity, then profile and optimize performance-critical portions in C++ as needed.

Happy hacking.

Share this post


Link to post
Share on other sites
Quote:

Yeah, I didn't think that there was a DirectX wrapping for Python, and I would like to apply whatever experience I gain from this towards future projects, so maybe C++ is the way to go.

Nah, the experience you gain towards future projects isn't going to be C++ or Python or DirectX. It's going to be straight programming. And that's language independent.
You might as well start with Python, take advantage of its ease of learning and fast development to teach yourself programming.

Then you'll have the best possible start for later C++/DirectX projects.
Trust me, as a newbie, grappling with DirectX won't give you any useful experience. At best it'll make you realize how much you still need to learn. At worst, it'll just depress the hell out of you. ;)
What makes a difference, is your programming skills, your ability to turn a problem into code, whether that code is C++ or Python. Once you learn programming, you can pick up new languages in a day or two. Guaranteed. [wink]

Apart from this, making a 2d RPG shouldn't require either C++ or DirectX. Python and SDL should be able to handle this with ease.

Of course, once you get to the 3d MMORPG with Doom 4 graphics and 100k players per server, you might want to switch to C++. But don't bother with it yet.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Binomine
That being said, vs. topics are always pointless. The reason two simular things exist is because they both do the job somewhat equally well

Not when someone has a particular project in mind.
Quote:
Original post by Max_Payne
As far as I'm concerned, C++ is more powerful, and more suitable for serious game development.

For a beginner not making a professional game (though even then...) I don't see why you'd bother with C++. Anyone who discounts anything but C++ for serious projects simply because it's popular probably hasn't ever had more than an entry level job for a summer or two.

In any event, extending mission critical portions of Python with C/C++ is pretty trivial so why bother to not do that? I hate to be the one to break it to some, but we're not in the 90's anymore, you can get away without unrolling loops in your menu screens.

Share this post


Link to post
Share on other sites
Heheh. Well, with my experiments with Python, it does seem a little easier to work with, and looking at some example code with the higher level C++/DirectX stuff makes my brain spin.

Lots of useful ideas though. Thanks for the insight!

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
For a beginner not making a professional game (though even then...) I don't see why you'd bother with C++. Anyone who discounts anything but C++ for serious projects simply because it's popular probably hasn't ever had more than an entry level job for a summer or two.


Quite arrogant for an anonymous coward. I'd say you haven't ever programmed a 3D engine yourself. I have, and I have also developped complete software in Python. I don't find Python helps that much with development speed. It has a few nice libraries, but unfortunately lacks in many areas.

Why would a begginer want to use C++? Because that begginer would learn much more that way, because you have access to a much wider range of libraries, because it *will* give you much more performance, and because its an industry standard. I can now say I am a quite competent C++ programmer, and I have learned alot. Many people don't realise the importance of the insight into how programming languages are implemented. Its a sad thing, because it really makes you a much more powerful programmer to know how things really work under the hood. Just ask John Carmack.

The main thing Python will give you is portability. The rest can all be done quite easily in C++. After programming in Python everyday for a few months, I don't find C++ restricts me at all. In fact, I would say the amount of code necessary to perform similar functions is very comparable in Python and C++.

Lastly, why would a begginer choose C++? Because that begginer might require support, and there are plenty of people around here who know C++, and have experience with game development in C++. No doubt you can get support for development in Python, but it will be harder to find people experienced with game development in Python. Not to mention that it would be easier to recruit a team of other hobbyist C++ programmers for a team project.

Share this post


Link to post
Share on other sites
Quote:
Original post by Oluseyi
Quote:
Original post by mumpo
Quote:
I'm pretty sure from what I've read that if I want to use DirectX (Direct3d is what I was previously thinking), I'd have to use C++.
...if you are refering to Python, then I believe you are correct; I have never heard of Direct3D bindings for Python.
bzzzt! Wrong.

All you need is PyWin32, which comes with the ActiveState ActivePython distribution or can be downloaded here. This is a set of Win32 bindings including COM, and, as we all know, DirectX is exposed via a collection of COM interfaces... Of course, you need to be fairly well versed in COM to use DirectX that way, but you can find a few examples on the 'net.

Thanks Oluseyi. I did not know that; I will have to check that out. Although, if you have to do it the raw COM way it probably won't help Arydrall much.

Share this post


Link to post
Share on other sites
Hey, I'm willing to learn whatever I have to. And while this information may not help me now, it gives me an idea of what is possible. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Max_Payne
Quite arrogant for an anonymous coward. I'd say you haven't ever programmed a 3D engine yourself. I have, and I have also developped complete software in Python. I don't find Python helps that much with development speed. It has a few nice libraries, but unfortunately lacks in many areas.


Just being curious, what was it you found lacking?

Personally I wouldnt do any larger project in python without TDD, or atleast some unit-testing. There are some things that can jump up and bite you in a dynamic language that you are protected from in, for example, C++. Luckily TDD works really well in Python, whereas compile times in C++ make it a bit more painful.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Max_Payne
Quite arrogant for an anonymous coward. I'd say you haven't ever programmed a 3D engine yourself.
I'm a professional OpenGL programmer. I use Asm, Python and C++ among other things. I'm not going to argue with you on this as an anon so whatever.

Quote:
Original post by Max_Payne
Why would a begginer want to use C++? Because that begginer would learn much more that way, because you have access to a much wider range of libraries, because it *will* give you much more performance, and because its an industry standard.
It will give you more performance at the cost of a slower start. Learn much more? If you mean spend time getting mixed up with C++'s syntax when you could be learning algorithms and logical thinking. I've been spending some time at a university teaching non-credit programming and graphics programming courses in my free time and I'm sharing with you my observations over a fairly good number of people.

Quote:
Original post by Max_Payne
I can now say I am a quite competent C++ programmer, and I have learned alot. Many people don't realise the importance of the insight into how programming languages are implemented. Its a sad thing, because it really makes you a much more powerful programmer to know how things really work under the hood. Just ask John Carmack.
I don't see what that has to do with beginning software programming. Why didn't you start with assembly then, what with all that you'd learn about how things really work.
Quote:
Original post by Max_Payne
The main thing Python will give you is portability. The rest can all be done quite easily in C++. After programming in Python everyday for a few months, I don't find C++ restricts me at all. In fact, I would say the amount of code necessary to perform similar functions is very comparable in Python and C++.
What'd you work on? Let's see some code. If you're doing nothing important or clever, than your argument holds perfectly well. You may as well write it in Blub.
Quote:
Original post by Max_Payne
Lastly, why would a begginer choose C++? Because that begginer might require support, and there are plenty of people around here who know C++, and have experience with game development in C++. No doubt you can get support for development in Python, but it will be harder to find people experienced with game development in Python. Not to mention that it would be easier to recruit a team of other hobbyist C++ programmers for a team project.
Yeah, a C++ group. The success ratio is huge for that set. I've found the pygame users lists much more successful in terms of "lets start making a game" to "hey, here's a release of our game" than the help wanted ones here.

I've been following your project and I congratulate you for sticking with it. I have a lot of respect for you. However, I don't think that you've gotten very far for the time you've put into it and that may or may not be related to you starting as a beginner in a tough language. In any event, I don't want you to be irate, I'm just stating my opinions and observations. Cheers.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous Poster
It will give you more performance at the cost of a slower start. Learn much more? If you mean spend time getting mixed up with C++'s syntax when you could be learning algorithms and logical thinking. I've been spending some time at a university teaching non-credit programming and graphics programming courses in my free time and I'm sharing with you my observations over a fairly good number of people.


A slower start at what exactly? Mixed up with the syntax? As far as I'm concerned, the C++ syntax is pretty darn obvious. The syntactic rules are basically the same as those of C and Java, and the compiler gives you very clear error messages when there is a problem. With python, however, you typically have to run the program to find out. Thats something I actually miss in Python, not being able to compile my programs to test for trivial errors, instead of having to run it and wait for an interpreter error to come up or an exception to be thrown.

In all the courses I've studied, I keep finding people that are puzzled over trivial implementation details. These people usually lack programming experience with C or C++, and lack knowledge of the intricacies of computers. Let me tell you one thing. Once you master C++, learning pretty much any other language (except perhaps OCaml) is trivial. I can't say the same thing about learning Python.

Quote:
Original post by Max_Payne
I don't see what that has to do with beginning software programming. Why didn't you start with assembly then, what with all that you'd learn about how things really work.


Interesting question, but actually, I find that C++ maps very well to the underlying hardware implementation. As a matter of fact, I programmed my own experimental virtual machines in C++ not so long ago, with a simple ASM compiler tailored for them. Understanding C++ has allowed me to understand ASM better.

Quote:
Original post by Max_Payne
What'd you work on? Let's see some code. If you're doing nothing important or clever, than your argument holds perfectly well. You may as well write it in Blub.


I'm working on an abstract benchmarking system which gathers statistics about various benchmark programs compiled and optimized in various different manners for a compiler research group. I would consider the code simple in nature. Most of it pretty much maps perfectly to C++ (apart from simple syntactic changes). But of course C++ doesn't come bundled with libraries for things like XML parsing.

Quote:
Original post by Max_Payne
Yeah, a C++ group. The success ratio is huge for that set. I've found the pygame users lists much more successful in terms of "lets start making a game" to "hey, here's a release of our game" than the help wanted ones here.


I've found there are many more games out here (both professional and hobbyist) written in C++ than in Python. This argument is pretty irrelevant because of its subjectivity.

Quote:
I've been following your project and I congratulate you for sticking with it. I have a lot of respect for you. However, I don't think that you've gotten very far for the time you've put into it and that may or may not be related to you starting as a beginner in a tough language. In any event, I don't want you to be irate, I'm just stating my opinions and observations. Cheers.


You haven't stated much observations in this debate. As for not getting very far, I would say that is quite inaccurate. We have completed two functional 3D engines in 4 years, which is alot for a group of student that works part-time on such a large scale project. We are now in the process of writing our third 3D engine, and I believe this one will be the right one ;)

I will admit that the main reason I'm not using Python is performance. For my applications, it would simply be unthinkable. However, I am serious when I say that I don't find it enhances productivity. As for the complexity of C++, I find its mostly a matter of getting used to it. From my perspective, Python is just another abstraction layer on top of a procedural language. Why would I need it, when I can clearly implement any Python feature I need in C++ in a way that will be more efficient, performance wise.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement