Rust
Programming Language
A brief tutorial by
-
Luís Cleto - ei11077
-
Miguel Marques - ei11099
What is Rust?
“Rust is a systems programming language that runs blazingly fast, prevents almost all crashes*, and eliminates data races.”
...
*
In theory. Rust is a work-in-progress and may do anything it likes up to and including eating your laundry.
Memory Safety
Rust's compiler statically determines when you need to allocate or deallocate memory, and inserts those calls itself.
“To err is to be human, but compilers never forget.”
Borrowing
There is a ‘data race’ when two or more pointers access the same memory location at the same time, where at least one of them is writing, and the operations are not synchronized.
Borrowing - Rules
- A borrow must last for a smaller scope than the owner.
- You must have:
- 0 or more references (&T) to a resource.
- Exactly 1 mutable reference (&mut T)
Other Features
- Lifetimes
- Macros
- Compiler Plugins
- Efficient C Bindings
- Conditional Compilation
- Unsafe Keyword
Others
- Object Oriented
- Concurrent Actor
Why Rust?
- Still growing (with Mozilla's help)
- Speed comparable to C/C++
- Safe
- Versatile
- Strong support for concurrency
Rust
Programming Language