Rust Vocational Training


Rust is a systems language with a strong focus on safety, efficiency and (safe) concurrency. Its development is spearheaded by Mozilla, although the vast majority of contributions to Rust come from external developers since Rust and its ecosystem are developed in the open.

Rust borrows heavily from functional programming languages to provide very expressive abstraction mechanisms. Because it is a systems language, these mechanisms are almost always zero-cost. For instance, polymorphic code has no runtime cost compared to a monomorphic version.

This concern for efficiency also means that Rust lets developers keep a very high level of control and freedom for optimizations. Rust has no Garbage Collection or any form of runtime memory inspection to decide when to free, allocate or re-use memory. But because manual memory management is almost universally regarded as dangerous, or at least very difficult to maintain, the Rust compiler has a borrow-checker which is responsible for i) proving that the input program is memory-safe (and thread-safe), and ii) generating a safe and "optimal" allocation/deallocation strategy. All of this is done at compile-time.

While ownership, the underlying principle of the borrow-checker, is often quite daunting for newcomers, Rust integrates this approach to memory management very nicely in the language. Huge efforts have been deployed to make this mechanism as natural as possible. In fact, most seasoned Rust developers internalize the borrow-checker and seldom actually think about it. For such developers, the borrow-checker is not a constraint: it only rejects programs because of typos, "minor oversights", or (very rare) deep architectural errors from the developer. Meaning, the borrow-checker rejects memory-unsafe programs. (The same, to some extent, can be said about thread-unsafe programs.)

At the end of the day, Rust is a language with C/C++-like performance with very expressive, zero-cost abstraction mechanisms from functional programming languages; it also generates the memory allocation strategy of the program automatically if one exists, and, if none do, can point precisely to what the problem is. It it also worth noting that Rust has an extremely ergonomic and powerful project/package manager, cargo, and shines in the quality of the explanation and suggestions that come with its compiler errors. It is thus not surprising that Rust is so popular: it has been voted "most loved programming language" in the StackOverflow developer survey for four years in a row, and has an impressive number of companies running it in production for a young systems language.

Layout

The session is divided in three parts:

  1. a beginner introduction to Rust's basics features (one day);
  2. crucial features and libraries for real-life development, along with a complex use-case used to showcase how to use them in a real project (two days);
  3. advanced/specific features (one day).

The road map below details the topics discussed in each part. Participants can chose to attend eitherthe whole session, parts 1 through 3, parts 1 and 2, only part 2, or parts 2 and 3.

Note that attendees planning to start at part 2 must make sure they are comfortable with the topics of part 1. This means, roughly, basic project management, having a basic understanding of ownership, and being able to write small programs that use some of the most common features of the standard library. Typically, this includes types Option, Result... and "simple" traits such as Write, Read, Display, From, Into...

Road Map

  1. Day 1: Introduction
    - basics: types and expressions, functions, using macros, user-defined types, loops, panic...
    - ecosystem: basic project management, dependencies, modules organization, rustfmt...
    - traits: simple polymorphism, defining and implementing traits...
    - ownership: copy/move semantics, references and basic lifetimes, slices...
  2. Days 2 and 3: Real-life Rust
    - macros: defining declarative macros, handling visibility...
    - traits: rules, extensibility, associated types, advanced polymorphism constraints...
    - ownership and memory: lifetimes, boxing, Copy and Clone, higher-order traits...
    - ecosystem: meta-attributes, documentation, testing, anatomy of medium to big projects...
    - must-know standard and extended (crates.io) libraries: iterators and collections, error-handling, simple but fearless concurrency over iterators...
    - complex use-case: showcase virtually all topics discussed so far on a (relatively) complex
    project (roughly 2~3kloc)
  3. Day 4 : advanced features
    - fearless concurrency: threads, the Send and Sync traits, mpsc, locks...
    - advanced traits: higher-kinded types, trait objects (dynamic dispatch), function pointers...
    - writing and using procedural macros
    - (relatively) shallow dive in unsafe Rust
    - complex use-case: showcase "fearless concurrency" and "advanced traits" topics on the complex use-case from days 2-3

NB: while the different parts of the session are presented in chronological order, the topics inside each parts only loosely represent the actual order in which they will be discussed.

Part 3 discusses relatively specific topics, in particular unsafe Rust and procedural macros. This is where the training has the most flexibility and can be customized depending on the participants.
For instance, it is possible to replace the discussion on procedural macros and/or unsafe Rust by a deeper dive into fearless concurrency and/or an exercise session where attendees can practice the notions seen so far (typically from part 2) while the trainer provides hints, help and insights when needed.

Open and Exclusive Sessions

So called "open sessions" are training sessions organized and hosted by OCamlPro in Paris, close to the Alésia metro station (line 4). These sessions are presented in French, although the slides are
in English. Open sessions do not provide any flexibility regarding part 3, except if all attendees agree on some modifications. For instance, trading the discussion on procedural macros for supervised exercises.

"Exclusive sessions" are training sessions given exclusively to a single company. These sessions can be hosted by OCamlPro or the company, although the latter depends on where the company is actually located. Compared to open ones, exclusive sessions let the company chose

  1. the language used during the session, between French and English (note that the slides themselves will be in English regardless), and
  2. most aspects of part 3 (the last day).

Workflow and Preparation

The whole session will rely heavily on examples. Attendees willing to follow along / experiment with the examples on their own machine during the session are encouraged to do so but should make sure they install Rust and setup a text editor or IDE appropriately.

Installing Rust is fairly easy on any mainstream operating system, see rustup for more details. Do
note that installing Rust using a package manager is not recommended: Rust has a relatively fast release cycle that does not mix well with the inertia of most package managers. Ideally, one should always use the latest version, and attendees should make sure their Rust toolchain is up to date. Unless they do not plan to write code at all.

Mainstream text editors and IDEs have Rust syntax highlighting either built-in or available as a
plugin. Beware that code completion is currently a bit difficult to add to some text editors.
IntelliJ-based IDEs usually support code completion perfectly thanks to the rust IntelliJ plugin.

It is also worth noting that Rust has a very nice online playground where one can write, build and run small programs. It constitutes a nice, hassle-free way to experiment with small examples without installing anything. Beware that attendees relying solely on the online playground will not be able to build, run or experiment with the complex use-case used in the session to showcase Rust features in the real world. This requires a local installation of the toolchain.

The trainer will use a terminal to run most commands and Sublime Text 3 (without code completion, but with error integration) to show and edit code during the session.

NB: attendees to the open sessions will be provided free wifi, although we can give no guarantee in terms of bandwidth. Again, attendees should make sure to have their environment setup beforehand to avoid last minute issues impacting the session, bandwidth-related or otherwise.

Pricing

All costs given below are for open sessions. Pricing for exclusive sessions depends on the number of participants and the actual location, contact us for an estimation.

Full SessionBeginnerIntermediateBeginner and
Intermediate
Intermediate
and advanced
3,500.00€1,500.00€2,000.00€3,000.00€3,000.00€
part 1-3part 1part 2part 1-2part 2-3
4 days1 day2 days3 days3 days