What is C++ used for?
To start off, I wouldn’t listen to anyone who says C++ is only or even mostly used in legacy systems. That is flatly wrong. Legacy is a major niche, but far from the biggest or only niche.
First begin by understanding who uses C++. There’s obviously the embedded space and performance driven native applications. I won’t touch on these because its they’ve been beaten to death by other comments. However, there’s also games and web applications to consider.
Web Applications:
A small peek at the Programming languages used in most popular websites per Wikipedia:
Top 5 Organizations by traffic:
Among 14 of the most popular modern websites, 5 use C++ somewhere in their backend systems. In fact if we sort the above languages all by how many of these organizations use them we get:
- Java (7 organizations used)
- C++/PHP (5 organizations used)
- JS/Python (4 organizations used)
- C#/Scala (3 organizations used)
- C/Erlang/Go/Hack (2 organizations used)
- D/Perl/Ruby/Xhp (1 organization used)
- Average Number of organizations at which language is used: 2.87
C++ lands squarely in second place tied with PHP in usage among these organizations’ back end systems. C++ is even used more commonly across these than JavaScript on the back-end at these organizations and is nearly twice as common as the average language across these groups. If we look at the top 5 most trafficked of these sites (Google, Facebook, YouTube, Yahoo, Amazon) then we can see that 4 out of the top 5 use C++ in their back ends (Yahoo being the exception).
C++ is used regularly on the backend when organizations are sufficiently large enough to justify investment in both horizontal-scaling and vertical-scaling. Devs at mid-scale companies will often underrate vertical-scaling and overrate horizontal-scaling, but both have utility. Horizontal-scaling refers to the process of simply adding more hardware to handle a scaling user-base, where vertical-scaling refers to the process of using better hardware or making better use of existing hardware to accommodate user-growth. For small-to-medium size projects and user-bases, the emphasis is proving features and minimizing development cost. In these cases it is cheaper to waste hardware resources on scripting code written by 3 cheaper devs running on a dozen servers than it is to waste capital resources on native code written by a 12 expensive devs running on 2 servers. However, as the user-base grows it becomes increasingly reasonable to justify the cost of optimization over the cost of adding more servers.
Put short: Features and hardware are cheap, optimization is expensive, and a LOT of hardware is the most expensive. C++ is an already-common performant solution with many modular design features which compromises a number of language goals in order to get the most out of the hardware resources your organization allocates. Thus at large user scale in back end web systems, the tightest-loops are often written in C++.
Games:
Per Wikipedia’s List of game engines, of the 181 game engines listed 54 don’t list their base programming language. Of the 127 that list their implementation language, 77 list C++. That’s a whopping 61% of specified game engines in that list implemented (wholly or partially) in C++. A few well known engines implemented in C++:
- Unreal Engine
Gears of War as well as so many others its not worth starting a list - Creation Engine
Skyrim, Fallout 4, Oblivion, anything Bethesda Game Studios - Cry Engine
Far Cry, Crysis, Monster Hunter Online, … - Id-Tech Engines 4 through 6
Anything to do with Doom, Wolfenstein, or Quake - Source Engine
Half-Life, Left 4 Dead, TF2, Counter-Strike
Where it concerns triple-A game engines, C++ is king of the languages because it is the most widely used systems language that gives bare bones execution on top of the metal while supporting proper systems design features.
Put short: C++ is among the top choices (if not the singular top choice) in triple-A game engines and development.
What is C++ used for?
C++ is used for writing applications where performance and proper resource utilization are considerable priorities worth investing in, while still maintaining a proper suite of language features capable of supporting distributed and modular development across an organization.