Curriculum/cpp-vs-rust-idioms
C++ vs Rust Idioms
memory model·L2 · idiom·stub
Replacesthe belief that Rust and C++ are interchangeable systems languages.
Same atoms (stack/heap, pointers, ownership); different defaults. RAII vs explicit drop semantics; exceptions vs `Result`; `shared_ptr` vs `Arc<Mutex<T>>`; templates vs traits + generics; CMake vs Cargo. The comparison crystallises ownership intuition — the same problem solved two ways, each language's choice exposed as a deliberate design move.
Unlocks—
Bridges
- raii-vs-explicit-dropshared mechanismBoth languages use deterministic destruction at scope exit (RAII / `Drop`). Rust makes the trait visible (`impl Drop for T { fn drop(&mut self) }`); C++ leaves the destructor implicit. Same mechanism; explicitness varies.
- zero-cost-abstractionsshared measurementBoth languages claim zero-cost abstractions. The claim is testable: compile equivalent code in both languages, compare the assembly. For simple iterators and smart pointers the assembly is identical; for async, error handling, and trait dispatch the cost shapes differ measurably.
This concept is a node in the curriculum DAG. The full lab — page blocks, done state, references — has not been authored yet. The relations above describe where it sits in the graph.
Author at: content/concepts/cpp-vs-rust-idioms/card.ts