Before we get started...

Everything is here:
https://github.com/jfcarr/rust-tech-talk

What Is Rust?

What Is Rust?

Rust is a multi-paradigm, general-purpose programming language.

Rust emphasizes performance, type safety, and concurrency.

Rust enforces memory safety - that is, that all references point to valid memory - without requiring the use of a garbage collector or reference counting present in other memory-safe languages.

https://en.wikipedia.org/wiki/Rust_(programming_language)

What Is Rust?

  • Performance: no runtime and no garbage collector
  • Reliability: rich type system and ownership model, memory-safety, thread-safety
  • Productivity: comprehensive documentation, useful error messages, and lots of tooling

From the Rust language home page

History

When What
2006 Personal project by Mozilla employee Graydon Hoare
2006 - 2015 Growing pains: language changed dramatically
2015 First stable release: 1.0
August 2020 Rust team affected by Mozilla layoffs
February 2021 Rust Foundation announced; founded by AWS, Huawei, Google, Microsoft, and Mozilla

Setup

Cargo

Crates Registry

Editor and IDE Support

IDE Extension / Addon
Visual Studio Code rust-analyzer
Eclipse Corrosion
IntelliJ IntelliJ Rust

Language Features

Data and Object Types

  • Declarations
  • Scalar: Integers, Floating Point, Char, and Bool
  • Compound: Arrays and Tuples
  • Custom: Enums and Structures
  • Std library types (e.g., String)
  • Std misc (e.g., Threads, Channels, and File I/O)

Flow Control

  • if/else
  • loop
  • while
  • for and range
  • match

Functions

Methods

Traits

Ownership

  • Resource Acquisition Is Initialization (RAII)
  • Moves (transferring ownership)
  • Borrowing (passing by reference)
  • Lifetimes

Modules

Crates

Generics

Macros

Error Handling

There is no try/catch!

  • panic! (unrecoverable conditions)
  • Option
  • Result
  • 3rd-party solutions (e.g., anyhow, thiserror, error-stack)

Testing

Unit test support is baked in.

Unsafe Code

Language Interoperability

Language Interoperability

C Interop

Language Interoperability

PyO3

PyO3 User Guide: https://pyo3.rs

Rust in Action

Name Description
Rust In the Linux Kernel Upcoming support for kernel modules. (Linux 6.0?)
Redox Operating system written in Rust
Android Open Source Project Google has announced support for Rust in the OS.
Bottlerocket Container distribution from Amazon Web Services with a build system written mostly in Rust.
mdbook Documentation generator. Heavily used by the Rust team, and others.

Reference and Documentation

Name Link
The Little Book of Rust Books https://lborb.github.io/book/
Rust by Example https://doc.rust-lang.org/stable/rust-by-example/
"The Book" https://doc.rust-lang.org/book/
The Rust Reference https://doc.rust-lang.org/reference/
Rust Cookbook https://rust-lang-nursery.github.io/rust-cookbook/
Rust Design Patterns https://rust-unofficial.github.io/patterns/