why c++ is the most widely used language for professional game development?

Started by
34 comments, last by jpetrie 9 years, 9 months ago

Most professional game engines like Unreal, Cryengine etc. uses C++ . Why c++ is the best language for game development. I want to ask the question as i want to be a professional game programmer in future and the answer will motivate me to learn more and more c++ in future. Please tell me is it really a good idea to be a expert in c++ for the sake of getting a job as a game developer. I know java and bit of C# , should i learn c++ in more in depth ? and what engine should i use in future? Currently i think it will be a good idea to use unity, as i'm a beginner. Thanks a lot, i really need your advise.

Advertisement

Most people using C++ does it because they have no choice. C++ is an old beast with tons of cumbersome issues, it's just that there are compilers for every single platform ever, so if you want to support every single platform ever (tm), then your only realistic choice is C++. Most engines etc are written in C++ but incorporate some form of scripting language which can then be used for the creation of the actual games.

I think the main reason is that C++ is low level programing language with OOP supported, because it's such low level you are less restricted, and with less restrictions you have more power to manipulate things... Also very good thing is that you have direct access to computer memory

Learning C++ won't be waste of time for sure.smile.png

As stated above, C++ is available for pretty much any platform you write games on. Most importantly, MS's, Sony's, and Nintendo's consoles all support C++ and rarely support anything else. (MS supported a stripped-down version of .NET on the 360 for XNA, but I'm not aware of any other examples)

Also, there is a ton of old legacy code written in C/C++ that would take a lot of time and testing (and more importantly, money) to convert to any other language.

And that's not to mention that pretty much any low-level system library is going to have C API. So even if you're writing in a different language someone somewhere is still going to be dropping down to the C way of calling functions to do things like open a file or draw a pixel on the screen.

Aside from the above reasons, C/C++ has a very strict policy of "you only pay for what you use" which makes it ideal for high-performance and resource-restricted applications. Which is basically what game programming on a console is. Most other languages have hidden costs (most commonly, garbage collection) that you cannot get rid of.

Of course, if you're not doing triple-A development, you may have a lot more freedom to pick your language as you aren't (typically) going to be making something for a console, and you can sometimes afford to trade code efficiency and speed for ease of development. Though I would argue that proper "modern" C++ is about as easy to work with as any "higher level" language except in certain edge cases.

Most modern and higher languages, like Java and C#, are running in a runtime (engine like program). So if there is no runtime for you particular platform, you can't deploy you game/program on that platform. So you are dependent to others.

C++ and C is compiled into machine code, which can be ran without any additional program. Furthermore, as other already stated, you have almost complete freedom to do anything in C++ and C. You can really mess around with pointers and your memory, which often results in very fast code. So the benefit is speed, which is very important in engines and games.

Blog: http://www.julianloehr.de

Twitter: https://twitter.com/jloehr_gamedev

HID Wiimote - Windows Device Driver for Wii Remote & Wii U Pro Controller: http://julianloehr.de/educational-work/hid-wiimote/


Most modern and higher languages, like Java and C#, are running in a runtime (engine like program). So if there is no runtime for you particular platform, you can't deploy you game/program on that platform. So you are dependent to others.
C++ and C is compiled into machine code, which can be ran without any additional program.
C/C++ are dependent on your platform having a decent compiler.

It's pretty good these days, but on the Wii, PS2, Xbox (original), the C++ compilers were teeerrriiiibbblllle! Any C++ games from that era were likely written in a very strict subset of C++, with a lot of plain C thrown in for good measure sad.png

In a game typical critical performance code areas could be resource and memory management. "High level", such managed and interpreted, programming language could potentially negatively impact on that area.

Since in "AAA" games usually every milliseconds matter, it is often reasonable sacrifice the high productivity of certain programming languages for the critical performance portions of the project and if you need to squeeze every possible milliseconds then native programming languages (like C and C++) are the tools you need.

C++ provides low level programming and supports a good range of programming paradigms (compared to C).

This two main "features" made C++ the "best fit" choice for AAA games for critical-performance-code areas and contribute to the continue development of solid and well performance compilers, libraries and frameworks (which are as well additional and strong incentives).

Modern C and C++ are also more portable than most people think, even (and especially) compared to "write once, run anywhere myth" languages.

"Recursion is the first step towards madness." - "Skegg?ld, Skálm?ld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Most modern and higher languages, like Java and C#, are running in a runtime (engine like program). So if there is no runtime for you particular platform, you can't deploy you game/program on that platform. So you are dependent to others.

MSVCRT says hi. (Hint: check what the acronym means.)

You are always beholden to others, no matter what language you use: MSVCRT, MSCORLIB, libstdc++, liblua - it has to be there otherwise you can't use it.

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]

Historically, games have been very performance sensitive, and few languages really target that demographic. Prior to C++, a lot of people used C. I suspect they jumped to C++ by and large simply because... well... at least it's better than C.

It's still used today largely due to inertia. There are competing languages like Rust and D, but none of them are stable enough that I'd use them for a multimillion dollar project like a game, and none of them have the library/tooling infrastructure in place that C++ does.


inertia

Frankly that's it.

It's the most popular because it was the most popular. There are some technical reasons, but this trumps them all. It's cause and effect too... due to it's popularity, tools exist. Tools exist because it is popular. It became the most popular because it was backward compatible with the previous most popular language.

Also, when Game Company X is going to start game Z after finishing Y using C++, what language are they going to use, the one they have workers proficient in and have a large existing code base, or something completely new with arbitrary advantages?

If Java or C# came out and were binary and source compatible with C++, just with modern syntax, type safety, better generics, etc... the industry would have switched ages ago. Well, if they were allowed to that is. Both Java and C# owe their existence to a single master, and that is another advantage ( and disadvantage ) of C++. C++ is run by committee, meaning no corporate lock in, but a glacial development cycle.

This topic is closed to new replies.

Advertisement