Outside of Unity, C# is rarely used as a game programming language. C++ is used heavily in Unreal, Cryengine, Lumberyard, and almost all proprietary game studio engines. This series is for Unity game programmers who know C# and want to broaden their skills so they can effectively write code for other engines, or even write C++ scripts for Unity. Today we’ll begin with an introduction to C++’s history, standard library, tools, community, and documentation. Read on to get started!

Table of Contents

History

C++’s predecessor is C, which debuted in 1972. It is still the most used language with C++ in fourth place and C# in fifth.

C++ got started with the name “C with Classes” in 1979. The name C++ came later in 1982. The original C++ compiler, Cfront, output C source files which were then compiled to machine code. That compiler has long since been replaced and modern compilers all compile C++ directly to machine code.

Major additions to the language were added with “C++ 2.0” in 1989 and the language was then standardized by ISO in 1998. Colloquially, this was called C++98 and began the convention where the year is added to name a version of the language. It also formalized the process of designing and standardizing the language via a committee and various working groups.

Minor changes to the language in 2003 resulted in C++03, but the “Modern C++” era began with huge changes to the language in C++11. This also quickened the standardization process from the previous eight year gap to just three years. This meant that we got minor changes in C++14, relatively big changes in C++17, and huge changes are about to be released in C++20. Game engines such as Unreal, Cryengine, and Lumberyard all support the latest version—C++17—and will likely support C++20 after it is standardized.

At this point the language has little resemblance to C. Much C code will still compile as C++, but idiomatic C++ is only superficially similar to C.

Standard Library

Every release of C++ includes what is called the “Standard Library.” This is often called the “STL,” meaning “Standard Template Library,” for its heavy use of a C++ language feature called templates. This library is also standardized by ISO along with the language itself.

The Standard Library is similar to .NET’s Framework Class Library or CoreFX. The architectural approach is for the C++ language to have powerful, low-level language features so more can be implemented in libraries instead of directly included in the language. For example, the language doesn’t include a string class. Instead, the Standard Library provides a string class that is efficiently implemented with low-level language features.

The following table shows the major sections of the Standard Library and their loose equivalents in .NET:

Standard Library Section C++ C#
Language support numeric_limits::max int.MaxValue
Concepts default_initializable where T : new()
Diagnostics exception System.Exception
Utilities tuple (int, float)
Strings string System.String
Containers vector List
Iterators begin() GetEnumerator()
Ranges views::filter Enumerable.Where
Algorithms transform Enumerable.Select
Numerics accumulate Enumerable.Aggregate
Localization toupper Char.ToUpper
I/O fstream FileStream
File system copy File.Copy
Regular expressions regex Regex
Atomic operations atomic++ Interlocked.Increment
Threading thread Thread

Some game programming environments do not use the Standard Library, or at least minimize its use. EA has implemented their own version called EASTL. Unreal has many built-in similar types (FString vs. string) and functions (MakeUnique vs. make_unique). These libraries benefit from the same low-level language features that the Standard Library is built on, but instead use them to efficiently reimplement what would be language features in many other languages.

Tools

The main tool is, of course, the compiler. There are many good options these days, but here are some of the most popular ones:

Compiler Cost Open Source Platforms
Microsoft Visual Studio Free and Paid No Windows
GCC (GNU Compiler Collection) Free Yes Windows, macOS, Linux
Clang Free Yes Windows, macOS, Linux
Intel C++ Free Yes Windows, macOS, Linux

There are also many IDEs available with the usual combination of features: a text editor, compiler execution, interactive debugger, etc. Here are some popular options:

IDE Cost Open Source Platforms
Microsoft Visual Studio Free and Paid No Windows
Apple Xcode Free No macOS
JetBrains CLion Paid No Windows, macOS, Linux
Microsoft Visual Studio Code Free Yes Windows, macOS, Linux

Many static analyzers, known as “linters,” and dynamic analyzers are available. The Clang sanitizers suite is free, open source, and has Unreal support. Commercial tools such as Coverity SAST are also available. Clang format and many IDEs can enforce style guides and automatically reformat code.

Documentation

The C++ standard is available for purchase, but almost no C++ developers actually buy it. A draft version is available for free and will be nearly identical, but it is extremely long and technical so it is also only a reference of last resort. Instead of the standard itself, most developers read reference sites such as cppreference.com just as they would read Microsoft Docs (a.k.a. MSDN) for C# reference.

Many guideline documents exist for C++. The C++ Core Guidelines, Google C++ style guide, and engine-specific standards are all commonly used. The C++ Core Guidelines, in particular, has a companion Guidelines Support Library (GSL) to enforce and facilitate the guidelines.

Community

There are many places where the community of developers congregate. Here are a few:

Next

With this introduction out of the way, next week we’ll dive into the language itself and start learning how to program in C++!