Programming Linux Games - Prototyping in Python
Its been awhile since I've posted on topics related to game programming. Basically I am here to talk about programming games in Python programming language. I have programmed in many languages including C and C++ and even developed graphics engines in these languages. Eventually I get to a point where the code is large and basically I sit pondering where to go next in order to add features, and also get lost in semantics of the languages and how I will accomplish these goals.
Next I started trying out python, in order to prototype new features. I have written rather large programs in python before, and the one thing I got out of it is that its very fast for writing programs, and also very type safe. So if you try to compare and int with a float, it will raise an exception. This sounds like a headache, but really its a dream for debugging later on!
Some problems you may be thinking is 1) Python is slow. Right you are, python is rather slow compared to languages like C++ and C, but only in specific cases. For example, iterating through arrays can be much faster in C and C++. Memory usage is also less because you are working with more primitive data types. Also python does constant checking of variable types, etc.
When it comes to games, I feel that today's processors are very fast. Not only that, but many of the heaviest tasks are getting put onto the GPU, which has limited choice in programming languages, and they are mostly low level. Tasks like physics, rasterization are now completely done on the GPU, and now the trend seems to be even using the GPU for general processing tasks (GPGPU).
Back to the point, python's speed limitations no longer apply considering we are pushing all the data to the GPU and allowing it to do all the work with its languages. There are some things left to the CPU, like event handling, playing sounds, and some basic math (debatable as to perform on GPU or CPU) which I think my quad core can handle quite easily thank you!
Further more, threading in python is very easy however you still need to be very careful as to how you set up variable access etc.
As I will show in future blog posts, using python for game development should become a reality because its so type safe, it allows you to program things quickly (functionally) and then allows you to push all the data to the GPU very easily. Currently I am working on a GPGPU processing program written in python, and it should come in under 1000 lines of code!