What power do Python posess as the programming language of a game?

Started by
16 comments, last by Geometrian 16 years, 9 months ago
Hi there! After a while of using Python I have came to wonder what power Python really posesses in the art of game development. I have noticed that Python programs run pretty slow, at least the ones that uses wxPython. What kind of games can you make and which ones are not recomended? How easy is it to to 3D in Python? Does the no-variable-declaration usually become a problem in larger applications or is it something one can live with? Can I use Pygame for a side-scroller game or is this really not recomended (this is what I've read), 'cause if I do 2D I really want to create side-scrollers and nothing else. Thank you in advance!
Advertisement
Quote:Original post by Zyndrof
Hi there!

After a while of using Python I have came to wonder what power Python really posesses in the art of game development. I have noticed that Python programs run pretty slow, at least the ones that uses wxPython. What kind of games can you make and which ones are not recomended? How easy is it to to 3D in Python?

Does the no-variable-declaration usually become a problem in larger applications or is it something one can live with?

Can I use Pygame for a side-scroller game or is this really not recomended (this is what I've read), 'cause if I do 2D I really want to create side-scrollers and nothing else.

Thank you in advance!


Python has the kind of power you can expect from a high level language, and "it's darn fast" if you consider the expressive power of the language itself (hint: a language isn't fast or slow). You're perfectly able to create 3D games with python AFAIK (remember that your graphic throughput does not depend that much on your CPU).

For the other questions, I'll let the Python Crew answer [smile]
Quote:Original post by Zyndrof
Hi there!

After a while of using Python I have came to wonder what power Python really posesses in the art of game development. I have noticed that Python programs run pretty slow, at least the ones that uses wxPython. What kind of games can you make and which ones are not recomended?

You could make any kind of game with it.

Quote:How easy is it to to 3D in Python?

That is a matter of opinion. Python has OpenGL bindings.

Quote:Does the no-variable-declaration usually become a problem in larger applications or is it something one can live with?

Again, that's a matter of opinion. However, if someone is using Python for a larger application, it likely won't bother them.

Quote:Can I use Pygame for a side-scroller game or is this really not recomended (this is what I've read), 'cause if I do 2D I really want to create side-scrollers and nothing else.

Where did you read that? There isn't really anything that is or isn't "recommended." What problems are you worried about here?

If performance really becomes an issue, you can rewrite the code that's giving you problems as a C module (possibly with using Pyrex), assuming you have exhausted possible algorithmic optimizations.
In my simpler applications (the "throw as many polygons onto the screen as possible" types), I saw a 1-1.5% decrease in performance in python when compared to C++. However, my C++ model loading program took 290 lines of function and class definitions and another 50 for setting up the window and the display routine. Needless to say, it was much quicker to develop in python.

I expect that my python performance will drop to 10-20% slower than equivalent C++ once I get some heavy game logic written.
Quote:What kind of games can you make and which ones are not recomended?
Any kind of game. If you select the correct libraries and/or engines and do a good job of the programming there's no reason any particular project would not be feasible in Python.

Some commercial games which use Python to varying degrees include Toontown Online (3d MMO built using Panda3D), EVE Online (another MMO, Stackless Python was used for the server and extensively in the client) and Civilization IV.

Quote:How easy is it to to 3D in Python?
Much like any other language. Python has bindings to OpenGL or you could look into PyOGRE or Panda3d if you're interested in some of the options for how you might create 3d games using Python.

- Jason Astle-Adams

I can't imagine why Python wouldn't run 3D. If you've ever used blender you'd know that it uses scripts written in Python to preform certain actions. I believe you can even write a game within blender using Python(fully 3D). So, yes, I think Python would do just fine in the 3D department.

~TDOT>
____________________________I'm 15, and beginning C#, and maybe Python. I'm fairly experienced in GML as well, and would be happy to help in GM related questions.
Python is really really slow. About 20 times slower than C/C++.

However, that doesn't really matter for casual games. The Python code only has to handle some simple game logic. Most of the work is for underlying libraries and drivers. And there is a certain advantage in development time.

So for a first game development experience Python isn't a bad choice. If you want to become a professional I'd learn C/C++ as soon as possible though. Maybe learn C# as an intermediate step, or if you don't plan on ever using the latest cutting edge technology.
Well, I'm going to the university to study economics. The latest cutting edge technology is really not required. Programming is mainly a hobby for me.

Therefore I don't want to learn a hundred different programming languages. I'm happy with one for each task, and Python seems simple and is cross platform and maybe it doesn't require any special installations on the users computer? Can I create for example a .exe file containing all the information that is needed for a Windows user to run my game without having either Python or pygame installed?
Quote:Original post by Zyndrof
Well, I'm going to the university to study economics. The latest cutting edge technology is really not required. Programming is mainly a hobby for me.

Therefore I don't want to learn a hundred different programming languages. I'm happy with one for each task, and Python seems simple and is cross platform and maybe it doesn't require any special installations on the users computer? Can I create for example a .exe file containing all the information that is needed for a Windows user to run my game without having either Python or pygame installed?


py2exe should do that for you. There's py2app for Mac, IIRC, and UN*X systems usually come with Python (or their users are supposed to be smart enough to install it). I believe there are also applications much like py2exe and py2app for UN*X-like systems ("freeze" was one, I believe).
Quote:Original post by C0D1F1ED
Python is really really slow. About 20 times slower than C/C++.

However, that doesn't really matter for casual games. The Python code only has to handle some simple game logic. Most of the work is for underlying libraries and drivers. And there is a certain advantage in development time.


According to that test, Java is also much slower than C++.

Would you consider MMO server a casual game?

In a recent experiment, I implemented a distributed MMO cluster (5 million distributed objects, 1.5 million messages per second - bottleneck becomes the network).

Java 6 implementation took around 5 hours, contains 25 classes, and uses nothing but out-of-box standard library. Entire application is completely asynchronous and lock-free.

The C++ implementation uses Boost::ASIO (IOCP under windows, with lock-free implementation), mostly static allocation, verified third-party lock-free containers, and some other Boost libraries. Development time of around 1 week, about half of that spent testing under Windows and Linux.

Java outperforms the C++ implementation by 30-50%.

The reason for this difference? Sun's JVM has one of the most advanced memory management technologies available, which automatically optimizes for cache-consistency, performs in-place allocation for short-live objects, does return value optimization, and more - something you need to painstakingly do yourself in C++.

I estimate that it would take me at least another week of writing custom libraries to mimic that functionality, and a lot of profiling of C++ code to match Java. Contrary to this, Java 6 offers completely lock-free containers and asynchronous primitives out-of-box.

Does that mean Java wins over C++?

The question is irrelevant. They are both languages. But C++ with Standard library simply doesn't provide even the most basic facilities for such applications. Java on the other hand gives them out of box, portable, tested and reliable.

C++ has benefits. But they are few and far between these days. Unless you already possess a huge, custom developed and tested library of all the advanced tools applications today need, you're looking at 6 month start-up time before you can catch up. Regardless of compiler, implementation or vendor.

But yes, Python is a good choice.

This topic is closed to new replies.

Advertisement