Programming languages

Rust

A systems language with memory safety and no garbage collector: C++ speed without its typical bugs.

What it is

Rust started as a personal project of Graydon Hoare at Mozilla. The first public version 0.1 came in 2012, and stable 1.0 in 2015. Today the Rust Foundation stewards the language, and open teams develop it.

The core idea is ownership and the borrow checker. At compile time the compiler guarantees there are no dangling references or data races, so no garbage collector is needed, and performance is close to C and C++.

Rust is used for browser engines, operating systems, CLI tools (ripgrep), WebAssembly and network infrastructure. It takes more time to learn than Go or Python.

Use it when

  • Performance and memory critical systems work: engines, drivers, embedded.
  • Secure network services where memory vulnerabilities are unacceptable.
  • WebAssembly modules and fast CLI tools.
  • Replacing hot spots in Python or Node.js with native code.

Avoid it when

  • A quick prototype or CRUD API where development time beats runtime speed.
  • A team that must learn the language fast: the learning curve is steep.
  • A project that leans on many existing JVM libraries.

Key concepts

Ownership
Every value has one owner. When the owner goes out of scope, the value is freed automatically.
Borrowing
References &T (many readers) or &mut T (one writer) without moving ownership.
Lifetimes
Annotations that tell the compiler how long references live.
Result / Option
Errors and missing values are expressed as types, not exceptions or null.
Cargo
The package manager and build system that ships with the standard toolchain.

Example

Counting words: Option instead of null.

Interview questions

  1. 1. What is ownership?

    The rule that every value has exactly one owner, and the value is dropped when the owner goes out of scope. Passing a value moves ownership, so the old variable is unusable afterwards.

  2. 2. How do &T and &mut T differ?

    &T is a shared read-only reference, and there can be many. &mut T is an exclusive reference for mutation, and there is only one. That is how the compiler prevents data races.

  3. 3. How does Rust handle errors?

    With Result<T, E> for recoverable errors and Option<T> for missing values. The ? operator propagates the error upward. panic! is kept for unrecoverable cases.

  4. 4. Why Rust without a garbage collector?

    Memory is freed deterministically when the owner goes away, so there are no GC pauses and less overhead. Safety comes from compile-time checks.

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).