Segmentation fault (core dumped)
Buffer Overflow
std::vector<bool>
template<typename T, typename = std::enable_if_t<...>>
Undefined Behavior

The Old Guard

"Trust me, I know what I'm doing with this raw pointer... oops."

(Don't hover too long...)

VS

The Ferris Way

"I won't let you hurt yourself, even if you try."

Stop Segfaulting.

Why spend your weekends debugging race conditions in C++ when the compiler can just yell at you on Friday afternoon in Rust?

See the Difference

The "Developer Experience"

cpp_pain.cpp
int* ptr = new int(10);
delete ptr;
// Later that night...
*ptr = 20; <-- USE AFTER FREE!

// No warning. No error. Just...
Segmentation fault (core dumped)

C++ Memory Management

Manual. Dangerous. Like juggling chainsaws while blindfolded on a unicycle. One mistake and your whole application crashes (or worse, gets hacked).

rust_joy.rs
let x = Box::new(10);
// x owns the data
let y = x; // Ownership moved to y!

// println!("{}", x); // Compile Error!
error[E0382]: borrow of moved value: `x`

Rust Ownership

The compiler tracks every variable. It knows who owns what. It won't let you make memory mistakes. It's safe by default.

📄📄📄

Header Files

#include <iostream> copies 30,000 lines of code into your file every time. Forgot #ifndef? Enjoy redefinition errors.

🧩

Modules

use std::io;. Clean. Namespaced. Only imports what you need. Zero copy-paste involved.

CMakeLists.txt (The Horror)
cmake_minimum_required(VERSION 3.10)
project(WhyIsThisSoHard)
find_package(Boost 1.69 REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(main main.cpp)
# Wait, why isn't it linking?
target_link_libraries(main ${Boost_LIBRARIES})
Error: Could not find Boost config...

The Build System Nightmare

You need a PhD in CMake just to include a library. Good luck if you're on Windows.

Cargo.toml (Pure Bliss)
[package]
name = "ez_life"
version = "0.1.0"

[dependencies]
serde = "1.0"
tokio = { version = "1", features = ["full"] }

# That's it. You're done.

Cargo: It Just Works

Add a line. Run cargo build. It downloads, compiles, and links. No tears involved.

The Billion Dollar Mistake 💸

NULL

C++: The "Null" Void

Employee* e = get_employee();
// Forgot to check if e is nullptr...
std::cout << e->name; <-- BOOM!

Did you check for null? Are you sure? What if the API changed? Runtime crash imminent.

?

Rust: The Option<T>

let e: Option<Employee> = get_employee();
// Compiler forces you to handle it:
match e {
  Some(emp) => println!("{}", emp.name),
  None => println!("Nobody here!")
}

Null doesn't exist. It's `None`. And you must handle it. Sleep peacefully.

Live Memory Leak Simulation

C++ Server (Forgot `delete`)

0 MB
Leaking...

Rust Server (RAII)

0 MB
Stable (Auto-Drop)

*Actual representation of a C++ backend service one hour after deployment.

Undefined Behavior Roulette

In Rust, indexing out of bounds is a panic. In C++, it's "Undefined Behavior," which means anything can happen. Let's see what happens today!

C++ Array Access

int arr[3] = {1, 2, 3};
cout << arr[999];
Waiting for disaster...

Rust Vector Access

let v = vec![1, 2, 3];
println!("{}", v[999]);
Waiting for panic...

The "Modern C++" Excuse Generator

📢
"It works on my machine!"

Press this whenever a C++ dev tries to explain why `std::variant` is actually ergonomic.

The Compiler Challenge

Click the button to compile a basic threaded application.

Ready to compile...
Ready to compile...