logo

Rust vs C++

Last Updated: 2021-11-19

Package Manager

Cargo is Rust’s build system and package manager, https://crates.io/ is the registry.

C++ does not have an official package manager.

Standard Library

Both have a standard library, and used like std::

Memory Safety

Rust provides memory safety without using garbage collection: it uses a system of ownership, which enforces and improves its memory safety across the board. It essentially removes the need for any manual memory management procedures. Rust supplies the built-in features for management procedures while C++ leaves that to you.

Recent updates to C++ has had new features like RAII (Resource Acquisition is Initialization) to get rid of manual memory management

Pointers

  • C++: std::shared_ptr and std::unique_ptr can be used like smart pointers.
  • Rust:
    • has several smart pointers in its standard library, like the reference counting smart pointer type.
    • does not allow null or dangling pointers