Rust: Epilogue

Rust: Epilogue

Rust is a big language. It is obviously very carefully designed, and with features for serious software development. Giving an intro in a few weeks has been a challenge.

There are a lot of things I wish I could have talked about…

Rust: Epilogue

Language features:

Rust: Epilogue

Data structures:

  • Slices: more flexible than arrays and lower-level than Vec.
  • String vs &str vs [u8].
  • Enums.
  • RAII.

Rust: Epilogue

So much cool stuff in the standard library:

The Other Rusts

We have been writing Rust and compiling to machine code, as one usually does. But there are some other contexts where Rust is written/​executed that are worth mentioning.

The Other Rusts

Rust has done a lot to keep us safe. Sometimes, those restrictions prevent specific memory manipulations that are necessary.

Rust can contain unsafe blocks and functions which remove a few of the language restrictions. In particular, you can follow a raw pointer in unsafe Rust.

The Other Rusts

Rust can be compiled to WebAssembly (wasm), so it can run in a web browser.

The Other Rusts

The Rust compiler can actually interpret a big subset of Rust. This allows many calculations to be evaluated at compile time.

This includes function calls, if, loops. Example: a const built from a loop. (Succeeds only in rustc ≥1.46.)

What Is Rust?

Rust has obviously borrowed a lot from Haskell and has many functional features (but there's no question it's imperative):

  • a type system that keeps us safe;
  • smart type inference;
  • carefully-managed memory;
  • typeclasses ≈ traits;
  • pattern matching, MaybeOption, etc;
  • lazy iterators.

What Is Rust?

It also has similarities to C++:

  • zero-compromise speed;
  • optimizing machine code compiler;
  • static typing/​binding;
  • no runtime environment (garbage collector, user threads, etc);
  • programmer can carefully manage memory.

What Is Rust?

I also feel many stylistic similarities to Python.

  • for loop is a for each;
  • type inference can make code look dynamic; ownership makes code feel garbage collected;
  • many programmer-friendly quality-of-life features (built-in testing, convenient data structures, big standard library).

What Is Rust?

But Rust also has a lot that isn't in any other (commonly-used) language: enforced ownerhsip and memory safety.

So, I don't know what Rust is. It's either the future, or it's from the future.