Rust vs C

What Does Rust Offer Over C?

Rust provides memory safety, concurrency guarantees, and modern tooling that C lacks, preventing common bugs at compile time.

Rust offers memory safety without garbage collection, fearless concurrency, and a modern package manager, whereas C requires manual memory management and lacks built-in safety guarantees. Rust's ownership system prevents data races and memory errors at compile time, while C relies on the programmer to avoid these issues.

// Rust: Memory safety enforced by the compiler
fn main() {
    let s = String::from("hello");
    let r = &s; // Borrowing is safe; compiler ensures s lives long enough
    println!("{}", r);
}