There has been a lot of debate about the best game development language, but we know there is none. Every language has its pros and cons – but a silver bullet? Forget it. Instead, when choosing a programming language, think about the objectives of your game. Do you want it to run across multiple platforms? Will it require high performance? And how quickly are you going to get the game to the market?
A lot has been said about the game development capabilities of conventional languages such as C++ and Java, but somehow Python remained largely unattended by the professional community. In this article, we intend to close this gap.
While Python is a general-purpose programming language which the likes of Google, NASA and Instagram use for robotics, data analysis, website development and much more, the language has a great potential in game development, too. Before we get to its key benefits and drawbacks, let’s see the real-world examples of Python powering some of the world’s most known computer games.
World of Tanks
This massively multiplayer online game with the community of over 100 million active players worldwide has Python at its core.
The well-known series of first-person shooters employs Python for the internal game logic, server controls and other tasks.
The Sims 4
A part of the best-selling video game franchise that has sold over 175 million copies globally (as of 2013), The Sims 4 topped the all-format weekly chart in its first week on sale and stayed there for two years. The game uses Python for modding.
Sid Meier’s Civilization IV
Multiple times Game of the Year, this turn-based strategy is mostly written in Python.
A massively multiplayer online role-playing game that reached over 500,000 subscribers in 2013. Python powers both the backend and the client side of the game.
What makes Python stand out among other languages is its clean and readable syntax. Almost every programmer will agree that Python code is more readable than that of Java or C. And while development speed may vary from project to project, it is widely agreed that making a game in Python is 5-10 times faster than making it in Java, not to say of C/C++.
In their book on Python development, Harrison Kinsley and Will McGugan said:
There are plenty of alternative languages that can be used to create games, but we have chosen Python because it has the tendency to take care of the details and leave you—the programmer — to concentrate on solving problems. For our purposes, solving problems means displaying game characters on the screen, making them look great, and having them interact with a virtual environment.
That said, for your game, all this means reduced development and maintenance costs as well as shorter time-to-market.
Extensive out-of-the-box tools
Python comes in handy with a vast standard library, well-designed built-ins and the availability of multiple third-party libraries and models for database access, math, statistics, COM and much more. With many pre-built programming tasks at their fingertips, developers can do more with less code.
With Python, you can try out new ideas and solutions in a day, not weeks, or you can even integrate prototyping in the development process. The language is agile by nature and makes refactoring easy, thus ensuring constant improvement of your game design and higher code quality.
Python is designed to easily call from and to C, C++ and Java code, so, say, the need to write performance-intensive modules of your game in C++ will not bring trouble. It is possible to write and debug code in Python and then convert it by hand into C++.
Python games perform smoothly on a platform, making support cost-saving and easy.
An interpreted language, Python is expected to run slower than compiled languages. However, according to Brian Curtin, a member of the Python Software Foundation board of directors and a core contributor to CPython, it’s all about separating the language from the runtime. “Certain benchmarks of Python code run under PyPy run faster than the equivalent C code or others,” he says.
As a dynamically typed language, Python requires considerable testing, bringing errors that only show up at runtime.
Pulling it all together
To end, the matter of language choice boils down to the goals you want to achieve with your game. If the runtime speed is crucial for your game, the best way is to write the engine in a language like C++ (though you can still do the scripting in Python). If it is not, you can deliver the game to the market as fast and as cheap as possible using a high-level language like Python. So, what’s your idea?