"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > C++ : speed obsession in the game industry

C++ : speed obsession in the game industry

Published on 2024-08-01
Browse:624

C   : speed obsession in the game industry

When do we really need speed

C became a standard language for games and graphics software a long time ago. And, there was actual reason -- work with real-time graphics and physics requires high performance. Processing geometry, managing buffers, matrix calculations - all of that does take time.
But, what about high-level logic? Game mechanics, user interface, storage management, network requests? Stability and safety are much more demanded there, than speed.

Responsibility distribution

We may implement performance-demanding functions in a compiled language, such as C , and call them from a program written in a dynamic language, such as Python.
But, today we already have well-documented and easy to use libraries for Python (pygame, pyopengl, pyassimp, pybullet, numpy), that are implemented primarily on C/C and do provide functions for heavy calculations, or physics/graphics in particular. We may never face necessity to implement such libraries on our own.

Is C the only choice?

It is generally accepted, that garbage collected languages, such as Java or C#, are slower than C and don't really meet requirements for heavy calculations. This is, of course, not true.
C may overcome Java or C# in performance by 20-30% in some special cases, but when it comes to runtime abstractions, such as dynamic function dispatch, languages interaction, asynchronous tasks, text or abstract collections management, Java and C# show much higher efficiency than C .
Also, we may run our Python programs on the same runtime with Java or C#, using Jython or IronPython. It brings a lot of benefits, such as shared garbage-collected memory, types system and easy access to C# or Java libraries right out of the box. On Java are implemented such nice dynamic languages as Clojure and Groovy, that have complete access to Java Class Library and share previously mentioned benefits.

What really makes influence on performance?

Today personal computers are much faster, than 15-20 years ago. But, most of desktop programs or games do not work as fast as expected (despite that they are still mostly implemented on C/C ). Today we need good algorithms and effective approaches much more, than just language speed. Function with constant complexity on Python is more preferable than function with linear complexity on C. To paint 100 trees by 15 lines of Python code is more preferable than to paint 500 trees by 300 lines of C code.

Care about game, not language

It is not really important, what language you use, when you don't have any game made, right?
Making game on C is much more demanding and exhausting, than doing same on Python or Ruby. When you would make 1 game with C , you would make 10 games with Python. When you would make 5 games with Python, it would be 0 games with C .
Let us care about games and fun, otherwise what the point?

Release Statement This article is reproduced at: https://dev.to/taqmuraz/speed-obsession-in-the-game-industry-1p4i?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3