What is C++?
Why C++ exists, what it powers, and your first look at a complete C++ program.
Your browser redraws this page 60 times per second. A big-budget video game simulates physics for thousands of objects at once. A stock-trading system reacts in millionths of a second.
All of that software has one thing in common: it's written in C++.
C++ was created by Bjarne Stroustrup at Bell Labs in 1985, and nearly 40 years later it still runs the world's most demanding software:
- Games — Unreal Engine and virtually every AAA game engine
- Browsers — the engines inside Chrome, Firefox, and Safari
- Operating systems — large parts of Windows, macOS, and Linux
- Databases — MySQL, PostgreSQL, MongoDB
- Cars, robots, and medical devices
If something has to be fast and reliable, there's a good chance it's C++.
Why is C++ so fast? Remember the compiler from the last lesson: C++ is a compiled language. All the translation work happens once, up front — the finished program is pure machine code running directly on the CPU.
Some other languages work differently: an interpreter reads their source code and translates it line by line while the program is running. That's convenient for quick scripts, but the constant translating adds overhead to every single instruction.
The trade-off is simple:
- Compiled (C++): slower to start developing (you recompile after every change), but the finished program runs at maximum speed.
- Interpreted: faster to tinker with, but the program runs 10–100× slower.
For a game drawing 60 frames every second, that difference is everything.
Why do game engines like Unreal use C++?
- AC++ compiles to machine code ahead of time, so the finished program runs at maximum speed
- BC++ is the easiest language to write games in
- COther languages cannot draw graphics
- DC++ programs never contain bugs
Here's a complete C++ program. Don't worry about memorizing it — the next lesson walks through every line slowly.
#include <iostream>
using namespace std;
int main() {
cout << "Hello, World!" << endl;
return 0;
}A quick preview of what you're looking at:
- The first two lines are setup — they make printing tools available.
int main() { ... }marks where the program starts.cout << "Hello, World!" << endl;prints text to the screen.return 0;tells the computer the program finished successfully.
When compiled and run, this program prints Hello, World! — the traditional first program in any language.
What does this program print?
#include <iostream>
using namespace std;
int main() {
cout << "C++" << endl;
cout << "Rocks" << endl;
return 0;
}- AC++ Rocks
- BC++ Rocks
- CC++Rocks
- DError
One reassurance before you dive in: C++ has a reputation for being hard. That reputation comes from its depth — C++ gives you control over details other languages hide. But you don't need all of that depth on day one.
This course teaches modern C++ — the current, cleaner style of the language (the versions called C++11 and newer) — one small step at a time. Modern C++ has safer, friendlier tools than the C++ of decades past, and you'll learn those tools from the start.
By the end of this course you'll understand not just C++ syntax, but how software actually works underneath — knowledge that makes every other language easier too.
Every C++ program that prints to the screen must include this line at the top:
#include <___>