====== The Rust programming language ====== ===== Motivation ===== The ability to read and write multiple programming languages is a requirement for computer scientists. Most languages have a tradeoff between speed of execution and safety. For instance, Python makes it easy to write slow, correct programs, while programs written in C are usually very fast, but it is tough to make them correct. As a result, the C language, while being easy to learn, takes years to master. The Rust programming language is a language that aims to 1/ be accessible to everyone, 2/ prevent programmers from writing whole classes types of bugs, and 3/ let programmers write efficient code. ===== Course description ===== This course is an introduction to the Rust programming language. We will start by learning some basic concepts (branches, loops, functions, structures, references, interfaces, etc.) and some parts of the standard library (strings, vectors, options, macros, I/O, multithreading, etc.). The design adopted by other languages and their associated tradeoffs are discussed. A special focus is put on the readability and reuseability of the code. ===== Objectives ===== After completing this course, students will be able to: * understand the structure, syntax, and semantics of the Rust programming language * understand the design choices made in Rust and their associated tradeoff * use parts of the standard library, as well as some other pervasive libraries * design, implement, and test a Rust program to solve real-life problems ==== Schedule ==== ^ **Date** ^ **Topic** ^ **Ressources** ^ **Exercises** ^ | 09.04.2025 | Intro to Rust | {{teaching:2025summer:rust:rust_intro.pdf | slides}} | {{teaching:2025summer:rust:installation.pdf | Installation sheet}} | | 09.04.2025 | Variables | {{teaching:2025summer:rust:main.txt | main.txt}} | {{teaching:2025summer:rust:exercise_rust_variables.pdf | Exercise sheet}} | | 17.04.2025 | More syntax: control flow, function | {{teaching:2025summer:rust:syntax.pdf}} | {{teaching:2025summer:rust:exercise_rust_control_flow_etc.pdf | Exercise sheet}} | | 17.04.2025 | First look at ownership | {{teaching:2025summer:rust:ownership.pdf}} | (see above) | | 17.04.2025 | Splitting code into modules | [[https://github.com/lrobidou/code_rust_course|code]] | (see above) | | 23.04.2025 | IO | {{teaching:2025summer:rust:IO.pdf}} | {{teaching:2025summer:rust:ex_02_io_trait.pdf | Exercise sheet}} | | 23.04.2025 | Trait | {{teaching:2025summer:rust:trait.txt | code}} | See above | | 07.04.2025 | Modelling, error, lifetime | {{teaching:2025summer:rust:rust_modelling_error_lifetime.pdf | slides}} {{teaching:2025summer:rust:option.txt | option}} {{teaching:2025summer:rust:lifetime.txt | lifetime}} {{teaching:2025summer:rust:destructor.txt | destructor}} | {{teaching:2025summer:rust:rust_model_iter_lifetime.pdf | Exercise sheet}} | | 14.05.2025 | Good practices | {{teaching:2025summer:rust:good_practices.pdf | slides}} | {{teaching:2025summer:rust:exercise_rust_mario_tsp.pdf | Exercise sheet}} | | 21.05.2025 | Unsafe & optimizations | {{teaching:2025summer:rust:unsafe.pdf | unsafe}} {{teaching:2025summer:rust:optimization.pdf | optimization}} | {{teaching:2025summer:rust:typestate_builder_pattern.pdf | Exercise sheet}} | | 21.05.2025 | Functional programming features | {{teaching:2025summer:rust:functional_style.pdf | slides}} | {{teaching:2025summer:rust:kmers.pdf | Exercise sheet}} | | 05.06.2025 | Manual parallel programming | {{teaching:2025summer:rust:parallel_programming.pdf | slides}} | {{teaching:2025summer:rust:parallel.pdf | Exercise sheet}} | | 11.06.2025 | Async | {{teaching:2025summer:rust:Async_in_Rust.pdf | slides}} | {{teaching:2025summer:rust:rust_ex_async.pdf | Exercise sheet}} | ===== Resources ===== ==== Learning Rust ==== * “The” Rust Book : https://doc.rust-lang.org/book * Interactive version with quizzes: https://rust-book.cs.brown.edu * Less wordy way of learning: https://doc.rust-lang.org/rust-by-example * Rust exercises: https://github.com/rust-lang/rustlings ==== Rust website ==== https://www.rust-lang.org/ ==== IDE used in class ==== You do not have to use a specific IDE. But if you use the same as me I might be able to help you a bit. * https://code.visualstudio.com I recommend using the following extensions: * https://marketplace.visualstudio.com/items/?itemName=rust-lang.rust-analyzer * https://marketplace.visualstudio.com/items/?itemName=dustypomerleau.rust-syntax * https://marketplace.visualstudio.com/items/?itemName=usernamehw.errorlens * https://marketplace.visualstudio.com/items/?itemName=tamasfe.even-better-toml I also recommend: * turning on “format on save” * using clippy for better lints ("rust-analyzer.check.command": "clippy"”) ==== Operating system used ==== You do not have to use a specific OS. But if you use the same as me I might be able to help you a bit. * https://www.debian.org ==== Optimizations ==== * explore the assembly generated by a program: https://godbolt.org * find performance bottleneck: https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html#gs.leob90 * intrisics of x86: https://db.in.tum.de/~finis/x86%20intrinsics%20cheat%20sheet%20v1.0.pdf