Home › Compare › Rust vs C (programming language)

Rust vs C (programming language)

From WikiTech, the encyclopedia of technology

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

RustC (programming language)
First release1972 (standardised 1989)1.0 in 2015
Memory safetyProgrammer responsibilityEnforced by the compiler in safe code
AbstractionsMinimal: structs, functions, macrosTraits, generics, enums with data, closures
Build toolingVaries: make, CMake, othersCargo, one standard tool
PortabilityCompilers for nearly every architectureGrowing; fewer targets
Undefined behaviourCommon pitfallConfined 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.