GPU Governor

Why C++ is Bad for Video Game Engine Scripting

August 2024 - 4 minute read

95% of game engines are built in C and C++. Despite the core of most game engines being developed in C++, many game engines avoid it for game logic programming. But why is this? First, we need to understand how a game engine works.

Project Image

How Game Engines are Made

Building a game engine can be broken down into several core systems. These include the rendering engine, physics engine, sound engine, scripting system, and more. Each of these systems typically has different performance requirements and coding challenges.

Why is C++ used for Game programming

Actually you can build a Game Engine in any language of your choice, However Game Engines utilizes graphics api's and all graphics api's are written in C and works natively with C++.

Challenges with C++ for Scripting

C++ is a powerful language, but it has its downsides when used for scripting in game engines:

Common Alternatives for Game Scripting

Due to these limitations, many game engines choose scripting languages that are easier to use for game logic. Common choices include:

Conclusion

While C++ remains essential for performance-critical parts of a game engine, using it for scripting adds significant complexity without much benefit. By combining C++ for the core engine and a high-level scripting language, game developers get the best of both worlds: high performance and ease of use.The main reason why C++ can't ever be a scripting language is because it's not an interpreted language but rather a compiled language, Although tools like cling which is an interpreted C++ exist (C++ with an interpreter instead of compiler).