Rust vs C (programming language)
A memory-safe systems language compared with the language that defined systems programming.
Overview
C and Rust are both used to write operating systems, embedded firmware and performance-critical libraries. C, created by Dennis Ritchie in the early 1970s, gives the programmer direct control over memory with almost no runtime. Rust offers comparable control but enforces memory safety at compile time through ownership and borrowing.
Both compile to native code without a garbage collector, and both can call each other through a C-compatible interface, which allows Rust to be introduced into existing C projects gradually.
Side-by-side comparison
| Rust | C (programming language) | |
|---|---|---|
| First release | 1972 (standardised 1989) | 1.0 in 2015 |
| Memory safety | Programmer responsibility | Enforced by the compiler in safe code |
| Abstractions | Minimal: structs, functions, macros | Traits, generics, enums with data, closures |
| Build tooling | Varies: make, CMake, others | Cargo, one standard tool |
| Portability | Compilers for nearly every architecture | Growing; fewer targets |
| Undefined behaviour | Common pitfall | Confined to unsafe blocks |
Choosing between them
C remains the default where toolchain availability, a stable ABI or decades of existing code dominate. Rust is attractive for new code that handles untrusted input or runs concurrently, where memory-safety defects are costly.
The Linux kernel accepts Rust for some new drivers alongside its C code, which illustrates how the two languages can coexist.
Read more
- Rust: A compiled systems programming language that enforces memory safety through ownership and borrowing without a garbage collector.
- C (programming language): A general-purpose, statically typed systems programming language created at Bell Labs in the early 1970s.