Saltar al contenido ForoHackers

Rust: start here

Rust
#3053 · · Citar · Denunciar

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

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder