पाठ 1 / 25

Why Rust

Safety without a garbage collector.

Memory safety at compile time

Rust is a systems programming language that prevents whole classes of bugs (use-after-free, data races, null pointer dereferences, buffer overflows in safe code) at compile time, without a garbage collector. Its ownership system tracks who is responsible for each value, so memory is freed predictably. The result is performance comparable to C and C++ with far fewer security vulnerabilities, which is why Rust is used in browsers, operating systems, cloud infrastructure, command-line tools and WebAssembly. The cost is a learning curve: the compiler is strict, but its error messages are unusually helpful.

Fast, safe, productive

Rust gives C-like performance with memory safety checked at compile time.

Three ideas: why Rust, cargo, crates.
Figure 1.1 — Rust, cargo and crates.

A strict but helpful editor

Rust's compiler is like an editor who refuses to publish a manuscript with errors but tells you exactly which sentence is wrong and how to fix it.

Read the whole error message

Rust errors usually explain the problem and suggest a fix; reading them carefully is the fastest way to learn.

त्वरित जाँच: How does Rust achieve memory safety?

  • Manual malloc and free only
  • A garbage collector running at runtime
  • Ownership and borrowing rules checked at compile time
  • Running everything in a virtual machine
Answer

Ownership and borrowing rules checked at compile time — Safety without runtime cost.