Rust is a systems programming language primarily targeting application areas where C and C++ have been used in the past.
The official website makes the case for Rust as follows:
- Performance: Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.
- Reliability: Rust’s rich type system and ownership model guarantee memory-safety and thread-safety – enabling you to eliminate many classes of bugs at compile-time.
- Productivity: Rust has great documentation, a friendly compiler with useful error messages, and top-notch tooling – an integrated package manager and build tool, smart multi-editor support with auto-completion and type inspections, an auto-formatter, and more.
Rust has been the most loved language in the StackOverflow survey since 2016.
Learning Rust for CS 137
Many projects have Rust as one of a few options for implementation language, so you may find yourself wanting to get up to speed with Rust quickly. Here are our favorite resources for learning Rust, in the order you might need to encounter them.
Our recommendation is to start with the Rust Book, then begin programming your project with internet searches and the standard library documentation as your guide. If you find yourself somewhat lost, try Rustlings or other resources.
It’s your choice how advanced you want to get with Rust in this class. Writing idiomatic Rust code will of course require more than just reading these resources, but idioms are best learned over time regardless.
Feel free to leverage course staff if you get stuck or want code quality advice.
Beginner
-
The Rust Book The official Rust book is a quick read, aimed at experienced programmers using Rust for the first time. For this class, we recommend reading chapters 1-8 and 11-12 at minimum. Chapter 9, Error Handling, will be helpful if you want to write high-quality code. Skim the headings of other chapters so you know to come back to them as-needed.
-
Rustlings If you want to take some time to get comfortable with Rust before diving into your project, Rustling’s is a test-driven approach to learning to read-and-write Rust.
Intermediate
-
Rust Standard Library Documentation Excellent documentation of the included batteries. For this class, the
collections
,io
,env
, andpath
modules are most likely to be useful, along with staples likeOption
,Vec<T>/&[T]
andString/&str
. -
Learning Rust with Entirely Too Many Linked Lists If you’re tired of “fighting the compiler” and want to take a step back to understand all-things ownership from first-principles, this is an excellent resource, if a bit wordy. For the purposes of this class, chapters 1-3 should be more than sufficient; 4-5 have a slim chance of being useful.
Rust Installation and Tooling
To install a rust toolchain, follow the instructions on the Rust website.
The easiest way to get a fantastic IDE experience for Rust is to use VSCode with the rust-analyzer
extension available from the marketplace. Note this is not the first result when you search Rust; do not install the “official” extension. If you’re not using VSCode, see the rust-analyzer manual.
If you want help writing high-quality code, clippy
is an excellent and easy-to-install linter.