Skip to the content ForoHackers
Log inJoin

Rust: start here

Rust
#3053 · · Quote · Report

Rust is a systems language that gives C-like speed and control without a garbage collector, and rules out whole classes of memory and data-race bugs at compile time. The price is a strict compiler and a new way of thinking about who owns each value. It is used for operating-system parts, network services, command-line tools and WebAssembly.

Key concepts

  • Ownership: each value has one owner; when the owner goes out of scope, the value is dropped.
  • Borrowing and lifetimes: references are checked so they never outlive what they point to, and mutable access is exclusive.
  • Enums and pattern matching: data that is one of several shapes, handled exhaustively.
  • Option and Result: absence and failure are values in the type, not null or exceptions.
  • Traits and generics: shared behaviour without inheritance, resolved at compile time.
  • Safe and unsafe: the compiler guarantees safety in ordinary code; unsafe blocks mark where you take over.

Vocabulary

  • Borrow checker: the compiler phase that enforces ownership and borrowing rules.
  • Crate: a unit of compilation and distribution; the package manager is called Cargo.
  • Trait object: a value used through a trait, with dynamic dispatch.
  • Fearless concurrency: the type system rejects data races in safe code.

What to study, in order

  1. The language's own introductory book, chapter by chapter, typing every example.
  2. Ownership and borrowing: write functions that fail to compile and read the messages.
  3. Structs, enums, pattern matching, Option and Result in a small command-line tool.
  4. Traits and generics; implement standard traits for your own types.
  5. Threads and channels, and why the compiler refuses shared mutation.
  6. Read and write a small amount of unsafe code and its safe wrapper.

Related tags

#c #cpp #memory-management #webassembly

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply