Ultimate Rust:Foundations

Course Description

The Ultimate Rust Foundations class starts with an introduction to Rust, and why you benefit from using – both as a foundation, and within your existing ecosystem.

Each session is 4 hours long.

Course Outline

Part 1: The Rust Ecosystem.

Rust includes Cargo, a swiss-army knife tool that can:

  • Create skeleton applications, with git integration built-in.
  • Provide a consistent build environment.
  • Execute and manage unit tests.
  • Benchmark your code.
  • Manage dependencies.

Using Rust without Cargo:

  • If you are including Rust as part of an existing application, you don’t have to use Cargo. Rust can integrate with a Makefile, Cmake or other build environment.

Rust’s Safety Guarantees

  • Memory Safety
  • Data-Race Protection
  • The “Borrow Checker”

Practicals:

  • Hello World application – the foundation of most languages.
  • Hello Library – build a Rust library in 5 minutes, including unit tests.
  • Benchmark: track your library’s performance over time.
  • Dependencies: build an application that uses dependencies with Cargo.

Part 2: Data Management.

  • Arrays, vectors, and slices.
  • Strict types and strong typing.
  • Serializing and De-Serializing data.
  • Iterative Programming – using iterators to combine operations.
  • Working with Strings – why are there two types of string, and why is a character a variable-sized type?

Part 3: Fearless Concurrency

  • Rust is designed from the ground-up to let you maximize performance, with threads and asynchronous execution patterns.
  • Protection from data races
  • Example C++ program that compiles without warnings, but gives the wrong results because of a data race.
  • Example of Rust not permitting an equivalent example to compile: you are protected against the most common concurrency errors out of the box.
  • Easy multi-threaded concurrency with Rayon
  • Ultimate control with raw threads
  • High-performance Input/Output with Asynchronous design and Tokio.

Practicals:

  • Build a CPU bound program with Rayon, and use all of your CPU power.
  • Manage raw-threads and shared data.
  • Spin up a simple server in 10 minutes.

Part 4: Traits, and Generics

  • Rust is not an object-oriented language – you can’t inherit functionality from one class into another.
  • Rust traits let you define an interface (with default behavior) and provide runtime or compile-time dynamic dispatch.
  • Rust generics let you tailor functions and types to the needs of the structure’s consumer.

Practicals:

  • The classic Object-Oriented Programming example of different objects printing different text – but with traits.
  • Designing a simple generic function with ToString.
  • Stacked traits – traits that depend upon one another, combined with generic programming.

About the Instructor

Herbert has been developing software professionally for more than 20 years. Starting with Pascal, and then moving onto C and C++, Herbert has developed custom applications ranging from web-server filters to games. Herbert is the author of Hands-on Rust and Rust Brain Teasers.

Important: Instructions to view the recording will be sent upon completion of the first session.