Why Rust

Rust, a language empowering everyone to build reliable and efficient software.

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 is already widely adopted!

Rust foundation platinum members:

Rust foundation silver members:

Strengths

Weaknesses

  • Steep learning curve; compiler enforcing (esp. memory) rules that would be "best practices" elsewhere.
  • Missing Rust-native libs in some domains, target platforms (esp. embedded), IDE features.
  • Longer compile times than "similar" code in other languages.
  • No formal language specification, can prevent legal use in some domains (aviation, medical, …).
  • Careless (use of unsafe in) libraries can secretly break safety guarantees.

XOR

[eXclusive OR] also known as exclusive disjunction is a logical operation that is true
if and only if its arguments differ (one is true, the other is false).

aliasing XOR mutability

Rust’s type system enforces the discipline of aliasing XOR mutability

  • (AXM, for short): a value of type T may either have multiple aliases
    (called shared references), of type &T, or it may be mutated via a
    unique, mutable reference, of type &mut T
  • BUT it may not be both
    aliased and mutable
    at the same time

null

null contd.

In computing, a null pointer or null reference is a value saved for indicating
that the pointer or reference does not refer to a valid object. Programs
routinely use null pointers to represent conditions such as the end of a list
of unknown length or the failure to perform some action; this use of null
pointers can be compared to nullable types and to the Nothing value in an
option type.

Option type

represents an optional value: every Option is either Option::Some(contains a value,
or Option::None(essentially null). Options are used
frequently in Rust with a number of uses:

  • Initial values
  • Return values for functions that are not defined over their entire input range (partial functions)
  • Return value for otherwise reporting simple errors, where None is returned on error
  • Optional struct fields
  • Struct fields that can be loaned or “taken”
  • Optional function arguments
  • Nullable pointers
  • Swapping things out of difficult situations
//       keyword
//       |      Type of returned value that will be
//       |      | held by `Some(T)`
//       v      v
pub enum Option<T> { // < Body of enum option,
    None,            // | When Option is unwrapped:
    Some(T),         // | it will be either `None`
}                    // < or `Some(T)`

Could Rust be a good fit for you?

  • what is interesting about Rust?
  • why do you like Rust?
  • what does the borrow checker do in Rust?
  • what is the best way to handle nullable types in Rust (hint: talk about the Option type)

General Concepts