Introduction
Python has managed to make a name for itself in today’s IT world as it has found its place in various areas, including web development, data science and machine learning. It has also become a popular choice for programming newcomers and gained recognition in educational purposes. There is one area, though, where Python still has not managed to claim the top spot – video games development. According to the 2022 Python Developers survey by JetBrains, about 9% of Python’s usage is distributed to game development and only 2% of the developers admit they utilize Python primarily in this field. While the significance of these results remains a subject to debate, the current state of the gaming industry as well as a general consensus among the community affirms the following: Python is not a primary language when crafting and developing video games.
Traditionally, C, C# and C++ have reigned as the dominant languages in the video game industry. However, times are slowly changing. It may come as a surprise, but in a few ways, Python, despite not being a historical choice, is now slowly emerging as a viable alternative. In this article I would like to present a few arguments to support this statement as well as discuss the potential future of Python as a prominent programming language in the domain of game development.
What is the present state of the game development scene?
The majority of modern games are developed using gaming engines. While there are occasional exceptions, it is a dominant trend for both small and large studios to direct their efforts towards development using widely available tools. According to a 2022 Game Engines and their use in Game Development survey, about 60% of developers utilize some sort of game engine and the numbers tend to rise each year. Among these tools, the most prominent ones are:
- Unity – a versatile and popular game engine based on C# and C++ languages. It is primarily favored by small studios and newcomers to the game development area. Unity has gained popularity, particularly in the indie games development scene, owing to its renowned large user community and the extensive repository of gaming assets.
- Unreal Engine – a high-end game engine based on C++ language and developed by Epic Games. It is renowned for its stunning 3D graphics and advanced rendering capabilities. It is also a go-to choice for the industry when creating visually impressive and cutting-edge AAA games.
- Godot – an open-source and community-driven game development tool, that, despite its young age, swiftly gains popularity within the indie gaming community. It stands out for its simplicity and adaptability. The engine is based on GDscript, an in-house language similar to Python’s syntax, while also offering integrations with both C++ and C#.
The rationale behind the perspective of using a dedicated, professional game development tool is simple, and can be represented in three points:
- availability,
- price,
- time.
Because video games development tends to be a long and costly process, all of the above principles must be achieved by precise resource allocation, code optimization and overall speed of the program execution. Mainstream video game engines, including the ones previously mentioned, typically provide numerous enhancements and tools aimed at achieving high efficiency in coding game programs as well as simplifying production processes by providing readily available asset stores. Furthermore, many of these engines are available for free use, at least to some degree of commercial applications, and, therefore, boast large communities of active users and developers.
This scenario has created a very constricted environment, where securing a significant share of the market proves to be challenging. Examining the results of the 2022 survey, we observe that Unity alone is the choice of almost 40% developers involved in the commercial gaming industry, with Unreal Engine at 15%, and Godot at 5%. These three options account for more than half of the distribution. Furthermore, among the 12 most widely utilized game engines, 11 are built upon C, C++ or C# languages or a combination of them, resulting in 80% of the overall distribution. C++, in particular, has firmly established its dominance in the gaming area as it is employed in most of the game development tools. These statistics do not account for in-house solutions, the majority of which align with this trend. Given the circumstances, the question arises: why has Python not yet not managed to find its foothold in this area?
Is Python too limited for gaming?
Undoubtedly, Python has rapidly grown to become one of the most popular and versatile programming languages in history, taking the first spot in most of today’s IT rankings. When examining Python’s most significant advantages, we usually include:
- high portability and versatility in usage,
- simple, clear, and readable syntax,
- massive community support.
In today’s programming landscape, focused on simplicity and increased code abstraction, one might have an impression that Python is a natural fit for game development. However, historical trends throughout past decades reveal a different story, and I would like to present two explanations for this divergence.
- The stage is already set
As mentioned earlier, the statistics make it clear that much of the game development landscape is firmly established. In this age of continuous product support people often lean toward existing solutions, resulting in the creation of sizable yet closed-off communities. The rapid evolution of game engine development has delivered 5 generations of both Unreal Engine and Unity, each progressively more advanced and aligned with the demands of today’s customers. A richness of online guides, tutorials and literature further contributes to the growth of these communities.
One important aspect of game development lies in the use of assets – pre-made components in the form of 2D/3D graphics, audio files and complete level or game physics blueprints, all accessible within a game engine. For instance, both Unity and Unreal Engine are renowned for their expansive stores overflowing with downloadable and purchasable content continually enriched by their expanding user base. Considering the previous point, it becomes evident that without a solid repository of available assets, it is likely for a new game engine or development tool to struggle to swiftly establish itself and meet customer expectations.
Moreover, during the era when numerous dominant game engines were being created, namely late ‘90s and early ‘00s, Python was still a relatively young language. It lacked several traits and characteristics it boasts today and carried an air of uncertainty, unlike established giants such as C or C++. This has led to a preference among developers that is only now beginning to change with the emergence of modern engines like Godot and its innovative GDScript language.
- Python’s limitations
I have pointed out the widespread use of C++ in contemporary game development. Despite its age, this language continues to play a vital role in scripting video games (often shared with C#) and, notably, in the program’s runtime.
Meanwhile, Python is an interpreted language, which inherently makes it slower in execution compared to compiled languages such as C++ and C#. This performance difference can be particularly significant when handling graphics-intensive and real-time computations, which are essential in game development and program runtime, especially in scenarios with limited resources. Although there are techniques for optimizing Python code, it may not match the efficiency of other languages dealing with resource-intensive tasks.
Secondly, Python abstracts many low-level details, which can be a disadvantage for game developers who require fine-grained control over hardware, memory, and performance. Python’s automatic memory management can lead to challenges related to garbage collection, potentially causing performance issues in specific scenarios. While there are numerous ways to optimize and reduce mentioned limitations of Python’s high-level implementation, C++ offers more immediate access to these low-level aspects, enabling precise low-level memory control and access to graphics APIs, audio hardware as well as other system-level functionalities. Additionally, C++ seamlessly integrates with libraries like DirectX and Vulkan, which are essential in game development, making it an appealing choice for developers. Although there are several Python packages compatible with DirectX (e.g. DirectPython), they are fundamentally built upon C++ extensions.
Is the truth different?
It might appear that Python has yet to secure a role in the realm of video game development, but the reality tells a little different story. It might come as a surprise to learn that Python has, in fact, played a significant role in the development of several notable games, ranging from small indie projects to renowned AAA titles within the industry. While the number of such instances may still not be overwhelming, they undeniably make Python’s footprint in the history of game development. To illustrate, consider the following extraordinary cases:
- Eve Online (2003 Sci-fi MMO game)
- Mount & Blade (2008 medieval strategy RPG)
- World of Tanks (2010 MMO simulation game)
- The Sims 4 (2014 renowned life-simulation game)
These examples serve as solid evidence for the inclusion of high level languages in game development. While multiple of the mentioned games continue to heavily rely on the use of C++, Python has established itself as a versatile tool of scripting, automation and modding. Online games like World of Tanks and Eve Online consistently employ Python in their web server infrastructure. Furthermore, titles such as The Sims 4 allowed their user community to craft unique fan modifications using Python code as their creative medium. Notably, all of these featured games continue to be supported and developed, whether by the developers themselves or by the community of dedicated players.
The realm of scripting and modding stands as the domain where Python might truly shine in gaming development. Historically, this area had been dominated by C# and C++ within the majority of modern gaming engines, owing to their performance superiority. However, in recent years, several studios have actively explored Python as a viable alternative, drawn to its straightforward syntax and portability traits. Even industry giants like Unity and Unreal Engine have embraced Python in their later versions, enabling new options for scripting. According to the documentation of both engines, a dedicated Python integration offers the following benefits:
- Automate repetitive tasks with simple Python scripts to speed up the artistic processes.
- Increase engine’s interoperability with other software of the pipeline that already uses Python.
- Make it easier to create and maintain large-scale asset management systems.
Unreal Engine goes even further by enabling the creation of customized Python-based UIs, utilized to manage the main editor. Moreover, Unreal allows using Python to procedurally generate designed levels. This represents a monumental advancement in game development, marking a significant milestone for Python. It also paves a way for a future where Python may play a more extensive role within modern game engines or even forecast its dominant utilization in tools to come.
There is another noteworthy aspect to explore. Python boasts a passionate community of dedicated game enthusiasts, fostering the creation of custom video games through authorial tools and engines. While these implementations still remain a niche within the domain, they have captivated the interest of numerous young developers. Python’s accessible and straightforward syntax, along with its high level of abstraction, makes these tools an excellent entry point for newcomers in the realms of game development and software engineering. Notably, among the most favored game engines constructed using Python are:
- PyGame – the most favored pure-pythonic choice for a library that serves as a framework for crafting 2D games, multimedia applications, and interactive simulations. While not a full-fledged game engine, Pygame offers an abundance of modules and tools for developing video games. Its key features, including simplicity, accessibility, cross-platform compatibility and seamless integrations with other media libraries, have proven invaluable to developers. With Pygame, they both recreate classic games like Snake, Arkanoid or Pac-Man through YouTube tutorials and challenges, and embark on crafting their own original 2D games.
- Blender – an open-source 3D computer graphics software application, used primarily for 3D content creation, modeling and rendering. It is renowned for its wide-ranging capabilities, extending across numerous industries, including video games development. One of Blender’s notable features is its robust utilization of Python as a primary scripting language. While C and C++ take the lead in handling most physics, audio and startup tasks, Blender incorporates an embedded Python interpreter that activates upon program startup and remains operational throughout its runtime. This interpreter plays a vital role in scripting tasks, including drawing the user interface and facilitating several of Blender’s internal tools.
- Ursina – a free, lightweight, open-source game engine that distinguishes itself by being built on top of Python and the Panda3D rendering engine. It enables the creation of both 2D and 3D games. What sets Ursina apart is its commitment to a high-level, user-friendly approach to game development, firmly rooted in Python. The engine is supported on multiple platforms and provides numerous integrations, including compatibility with the previously mentioned Blender tool. While Ursina may not ascend to the complexity and sophistication levels of its competitors, it has fostered a dedicated community of eager game developers and can boast 1.9k stars on Github at the moment of this article’s writing. The engine particularly signs in the realm of rapid prototyping and may appeal to developers who cherish a more Pythonic approach to game development.
- Pyxel – a free, open-source Python retro game engine and framework for creating 2D games. It is a true treasure trove for retro pixel-art style enthusiasts as it embraces a deliberate design constraint to harness a palette of just 16 colors and 4 concurrent sounds. Its elegant simplicity and nostalgic visual style have turned it a prime choice for newcomers to game development or retro enthusiasts craving for a dose of nostalgia. Pyxel boasts cross-platform compatibility, comprehensive guidance for initiating and advancing authorial retro game projects, and an extensive community presence, marked by over 12k stars on Github.
Python, while somewhat limited in resource management and optimization compared to other dominant languages in the game development field, has undeniably made a noteworthy mention mark. Although the provided examples may not rival the cutting-edge engines that hold important positions in the realm of gaming industry, they offer a promising glimpse into the future. Popularity of tools like Ursina or PyGame serve as compelling evidence for Python’s most vital attribute: rapid implementation. This quality has proven invaluable in the contemporary development landscape, where the increasing costs and complexity of video games demand swift execution.
How long it takes to write a string processing application in various languages.
Numerous tests and surveys have demonstrated Python’s remarkable efficiency in development, often outpacing popular alternatives like C, Java or C++. The continued adoption of Python in these areas holds the potential to reduce development costs and enhance game creation, making it a more organized and accessible undertaking. Combined with Python’s universal and advanced use in AI development, it may revolutionize game engineering.
Lastly, it is important to highlight the significant optimizations in Python execution time that accompany each new release. In fact, Python has made substantial progress in enhancing its performance, building on improvements since its early iterations. Numerous tests conducted by data analysts confirm a 40% increase in performance in Python 3.11 compared to its 3.7 version. The latest iteration, Python 3.12, elevates execution speed even further, employing a range of techniques including enhanced multi-thread parallelism and more efficient memory management. Future releases are expected to prioritize further optimization, which may prove vital in solidifying Python’s standing within the game development arena.
How does the future present itself?
The current state of the gaming industry seems firmly established, standing on the foundations of modern specialized engines, utilizing low level languages like C++ and drawing from existing solutions. All things considered, it may appear challenging for a new competitor to break into the stage, especially based on an unexploited language in this domain, such as Python. However, as time progresses, we are witnessing Python’s gradual and confident emergence as a viable alternative. Due to its straightforward syntax, improving performance and high recognition in the industry, this language finds its place in the scripting process, automation in largest players in the field, and even in the genuine runtime of small proprietary game engines and gaming frameworks. This trend may lead to reducing various development costs in game engineering, particularly due to Python’s renowned simplicity, development speed and widespread usage in AI. While we are yet to witness a successful enterprise-level game engine running exclusively on Python, and we understand that this shift may not happen overnight, I hold a strong belief that, with a few further improvements towards optimization and low level management, Python may, at some point, revolutionize the gaming industry and propel it to the next level, both in terms of programming abstraction as in the capabilities of the future games.
Sources
- https://lp.jetbrains.com/python-developers-survey-2022/
- https://www.slashdata.co/blog/did-you-know-that-60-of-game-developers-use-game-engines
- https://www.netguru.com/blog/python-vs-c-sharp
- https://www.javatpoint.com/c-sharp-game-development
- https://medium.com/pyslackers/yes-python-is-slow-and-i-dont-care-13763980b5a1
- https://gamerant.com/best-games-that-use-python/
- https://docs.unity3d.com/Packages/com.unity.scripting.python@7.0/manual/index.html
- https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/ScriptingAndAutomation/Python/
- https://www.pygame.org/news
- https://www.ursinaengine.org/
- https://github.com/kitao/pyxel
- https://docs.blender.org/api/current/info_quickstart.html
- https://www.tomatolist.com/show_blog_page.html?no=391edf21-e71b-4a52-a8bf-3b24c9faf3b5