Hacker News new | ask | show | jobs
by tompko 4645 days ago
For console games C++ is unlikely to be replaced in the near future, although an ever increasing portion of the game code is likely to be written in a scripting engine on top of and underlying C++ base. Of course, the main reason that the engines are written in C++ is that that's what the toolchain provided by Microsoft/Sony/Nintendo supports, so there aren't really any other options unless you want to write your own compiler. There are however a few good reasons to use C++ for console games.

Console games have some fairly unique restrictions which are difficult to meet in other languages. The most major one being that they usually have predefined memory usage maps, and often disallow allocation/deallocation for large parts of their runtime. This means that garbage collected languages aren't really an option unless you have tight control over the collection itself. Also to squeeze as much data into as little memory as possible games often use custom allocators which can take advantage of the fact that the memory layout is mostly known ahead of time and is mostly static.

The other bonus of C++ is that you can drop down into assembler, either to speed up a certain portion of code, or to work around a bug in the compiler chain. Because the toolchains tend to be targeting fairly unique systems, they tend not to be as mature as toolchains for the PC so both of these situations can, and do, occur.

With the ever increasing amount of memory available in consoles it's possible that they'll reach a point where they won't have to have as tight a control over the memory, but mostly when extra memory is available it's quickly filled with larger textures, more detailed models, higher fidelity physics maps, or more AI agents.