C++ is based on the C language, and was created by Danish computer scientist Bjarne Stroustrup in the 1980s. It is a very efficient language because it gives the programmer direct control over the computer's hardware, and it doesn't need any "middleman" that other languages need. Imagine it like this: Python and similar languages are giant automatic luxury tour buses — they are comfortable and you don't need to worry about shifting. C++ is like a race car — you must shift, it has no safety features, BUT you can go as fast as possible.
C++ is a hybrid language. This means it is an object-oriented programming language (OOP) and has features from other types of languages. An OOP means that you don't have to write a large, confusing list of instructions. You just have to build groups which "talk" to each other. For example, if you want to make a nice cake, you can of course write everything into steps. A complicated cake can be up to 40 steps, and if you mess up one step, it will all be a disaster. However, imagine you can break the job down into separate, independent stations:
- The Oven station (only cares about baking)
- The Fruit station (only cares about chopping the fruits)
- The Frosting station (only care about mixing sugar)
Each station does not care how the other stations do their jobs. They only talk to each other by passing information to each other: the fruit station gives the chopped strawberries to the frosting station, which puts them on a cake. If the frosting machine breaks, the oven still works perfectly. You only have to fix the frosting machine without ruining the whole bakery.
Another example: Super Mario. Without an OOP language, you must code the whole game in one script. If you make one small mistake in the code, the whole game can be ruined. However, with OOP, you can create seperate
objects which only care about their own jobs.
- The Mario object (only contains code for moving, jumping, keeping track of his lives)
- The Goomba object (only contains code for Goomba, so walking left or right, falling off cliffs, etc. Goomba has no idea about how Mario jumps)
- The Coin object (just sits there, spins around, and waits)
They talk to each other, when for example, Mario's object moves and touches Goomba's object. Mario's object sends a message to Goomba. The Goomba object processes the message internally, then triggers its own "squish" animation and deletes itself. Mario's object then tells the User interface object to add 100 points.
So now that you understand OPP, what is C++ used for nowadays? It is often used for game development and engines, operating systems (like Windows, Apple's macOS, etc.), database management systems (like MySQL), financial infrastructure, web browsers (Chrome, Safari, Edge), aerospace systems, smartwatches, autonomous vehicle navigation, and even in parts of AI.