---
# System prepended metadata

title: 'RSH 017 Internal: rust'

---

# RSH 017 Internal: rust


## About RSH
- Started in ~april
  - show website with overview of past sessions 
- Goal, reach people in a better way
- Remind and show hackmd
- Today is unusual time


## Material

- https://github.com/dev-cafe/rust-demo
- https://github.com/annefou/rust-examples


## About Rust


### Why Rust

- "A language empowering everyone to build reliable and efficient software." (https://www.rust-lang.org)
- Fast but also safe
- Zero cost abstractions
- Type system
- Compiler catches most errors (if it compiles, it often just works)
- Compiler provides helpful error messages
- Memory safety
- Thread safety
- Private and immutable by default
- Great tooling (testing, documentation, auto-formatter, dependency management, package registry, no makefiles needed)
- Community
- Most-loved programming language in the 2016, 2017, 2018, and 2019 Stack Overflow annual surveys


### History of Rust

- Originally designed by Graydon Hoare at Mozilla Research, with contributions from Dave Herman, Brendan Eich, and others.
- Mozilla began sponsoring the project in 2009.
- Announced 2010: http://venge.net/graydon/talks/intro-talk-2.pdf
- Rust 1.0, the first stable release, released in 2015.
- Since 2011 `rustc` is compiled using `rustc`.
- `rustc` uses LLVM as its back end.
- The History of Rust: https://www.youtube.com/watch?v=79PSagCD_AY
- Firefox (components Servo and Quantum) written in Rust.
- Ad block engine in [Brave](https://brave.com/).
- `exa`, `ripgrep`, `bat`, and `fd` written in Rust (you really want these tools!).
- Great overview of tools written in Rust: https://www.wezm.net/v2/posts/2020/100-rust-binaries/
- [Discord](https://discord.com/) uses Rust for some of its backed.


### Memory model

- No explicit allocation and deallocation.
- No garbage collector either.
- Each value in Rust has an owner and there can only be one owner at a time.
- When the owner goes out of scope, the value is dropped.
- Rust knows the size of all stack allocations at compile time.

This does not compile:
```rust
let s1 = String::from("hello");
let s2 = s1;

println!("{}, world!", s1);
```

- Rust's memory is managed a bit like money: one owner, it can be borrowed.
- We can borrow references: https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#references-and-borrowing
- At any given time, you can have either one mutable reference or any number of immutable references.


toc marks
- about rust
- starting a new project
- demo of complete project using cargo
- rust on mybinder
- rust and python
- rust or mybinder, continued
- conclusion





## hello world


## pi example




## tooling
- cargo


## notebook



## interfacing rust with python/c/fortran

Radovan can show this if there is time