skip to content
consteval.dev

Introduction to C++

/ 3 min read

Updated:
Table of Contents

Why C++?

C++ is powerful because it gives you both speed and control. You can write code that’s close to the hardware but still elegant. Modern C++ is safer and easier, thanks to updates from C++11 to C++20. It’s tough at first, but it’s worth it for what you can build.

Quick look

Skip this if you know or are bored of evolutions.

  • C++98: The first standardized C++ – classes, templates, STL.
  • C++03: Minor bug fixes.
  • C++11: Modern C++ begins – auto, lambdas, move semantics, smart pointers.
  • C++14: Generic lambdas, return type deduction.
  • C++17: Structured bindings, if constexpr, parallel STL.(Compile time programming + Template MetaProgramming).
  • C++20: concepts, ranges, coroutines, modules.

How to Use C++ Without Losing Your Mind

Many developers dislike C++ because:

  1. They expect to learn it in a week (spoiler: it’s not that easy).
  2. The compiler errors don't make any sense sometimes.
  3. Managing memory and avoiding weird bugs (segfaults 🙂 are seriously scary) can be a real headache.
  4. The syntax can get pretty confusing and messy.
  5. There’s no one “official” build system, which makes setup tricky.

How’d you get out of it?

  1. Don’t rush.
  2. Be consistent and use C++ every day.
  3. Don’t be scared of new syntax. Practice it and understand the fundamentals — the why and how behind it.
  4. Once you get a good grip, study open-source projects to see how real-world C++ codebases are structured.
  5. Start by writing basic, working code — even if it’s slow. Then, optimize it using C++ features. Performance comes later.
  6. Stick to modern C++ features — preferably from C++11 and beyond.

What can you build with C++

Literally anything. Examples include

  1. Operating systems
  2. Game Engines
  3. Compilers
  4. Browsers
  5. Embedded Systems
  6. Artificial Intelligence (Yeah, Python devs might cry 😅 — but the core logic and performance-critical libraries are written in C++. Python is often just a wrapper.)

Getting Started

Ughhh 🙁 that’s a bit too theoretical. Let’s look at some actual code.

A Simple "Hello World" program

main.cc
#include <iostream>
int main(){
std::cout << "Hello World\n";
return 0;
}

Installing Clang

First, you need to install the compiler. Throughout this course, we’ll use clang++ because it’s generally faster and produces better diagnostics compared to g++ (GNU).

  • For MacOS: Run the following command in your terminal
Terminal window
xcode-select --install
  • For Ubuntu/Linux: Run the following command in your terminal
Terminal window
sudo apt update
sudo apt install clang
  • For Windows

Download LLVM and add it to Edit System Environments Variable path. Or just use WSL(Windows subsystem for Linux) and follow the same installation steps for Linux. 👉 WSL Installation Guide

Compiling the above code

We’ll start by compiling a single .cc file — no build systems yet.

In your terminal run:

Terminal window
clang++ main.cc -o main

This command compiles main.cc and creates an executable named main. The -o flag stands for “output” — it tells the compiler what to name the executable.

Now run it — and boom, “Hello World” shows up in your terminal! 🎉

I know — we’ve barely touched 1% of what C++ can do. And yeah, even writing “Hello World” might’ve felt a bit annoying or awkward at first (you’re not alone 😅). But stick with me. I’ll be dropping a bunch of posts that’ll make things click, and slowly you’ll start vibing with C++ like a real one.