Rust Vocational Training
- Length: from 1,5 to 5 Days
- Pricing for modules(tax NI): 1-2 = 1990€/person and 1-3 = 2490€/person
- Attendees: developpers
- Available remotely: yes
- Tutors: Adrien Champion
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.
- Master the main principles of Rust: ownership and traits
- Master the ecosystem: project management, dependencies, sub-project layout
- Master declarative macros
- Getting acquainted with standard and extended libraries in a pratical environment
- Using bound advanced polymorphism: higher-kinded types and associated types
- Manage concurring parts of a programme, understanding the safety guarantees the Rust offers in that context
- Some introduction to Unsafe Rust
PrerequisitesTo do the complete course:
Resulttypes, and simple traits like
Module 1 (1,5 days)
Basics : types and expressions,functions, using macros, user-defined types, loops and panic mode...
Ecosystem : manage a simplistic project, dependencies, organising modules,
Traits : simple polymorphism, define and implement traits...
Ownership : semantics of copy and move, refenrences and lifetimes, slice types...
Rust in the real World
Module 2 (2 days)
Macros : define declarative macros, handle visibility...
Traits : rules, extensibility, associated types, constraints of advanced polymorphism...
Ownership and memory : lifetimes, boxing,
Clone, advanced traits...
Ecosystem : meta-attributes, documentation, tests, managing mid to large projects...
Main standard and extended libraries (crates.io): iterators and records, error handling, “fearless concurrency” on iterators...
Complex use case : incapsulates virtually every concept presented in the course in a fairly complex project.
Module 3 (1,5 days)
Fearless concurrency : threads and traits like
Advanced traits : higher-kinded types, object traits (dynamic dispatch), function pointers...
Writing and using procedural macros
Discovering unsafe Rust
Complex use case : plain and complete introduction to “fearless concurrency” and “advances traits”
This course is modular! Participants may attend the entire session, or just modules 1 and 2, or module 2 alone, or stick to modules 2 and 3.
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 Session||Beginner||Intermediate||Beginner and Intermediate||Intermediate and advanced|
|4 days||1 day||2 days||3 days||3 days|
The session is divided in three parts:
- A beginner introduction to Rust’s basics features (one day);
- 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);
- Advanced/specific features (one day).
- 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…
- 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)
- 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
- The language used during the session, between French and English (note that the slides themselves will be in English regardless), and
- 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.
What is Rust?
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.)