1 min read

Walkthrough Intermission - Rust Part 1

Ah the travails of a journeyman programmer. I honestly switch back and forth between so many different languages and technologies.. and really remain a rank amateur at most of them. Super frustrating.

Alright, what is Rust.. (wikipedia) - basically a safe version of C++, designed for performance, safety and concurrency. As I learned when I tried to massively multithread on python, one of the modern challenges of programming is dealing with doing thing safely at massively parallel scale. Oh Python Global Interpreter Lock, how I loathed thee.

Best way to brush up on Rust, seems to be the go through The Book, so here we go.

Chapter 1

  • Rust has macros AND functions... we'll find out what they are later
  • rust is an ahead-of-time-compiled language, meaning you can pass someone else the built executable... instead of forcing them to have Python to run it
  • cargo new creates a nice little template with .gitignore and a git init already done and a nice little hello world which I think is awesome... I mean I remember lots of hunting to decide what a skeleton should look like in my early Python days

  • cargo build - build a project
    • Instead of saving the result of the build in the same directory as our code, Cargo stores it in the target/debug directory.
  • cargo build --release - compile with optimizations
    • creates executable in target/release
  • cargo run - build and run a project in one step using .
  • cargo check - build a project without producing a binary to check for errors using .
  • cargo doc --open - auto generates html documentation including dependencies... what a beautiful function really

So nice... really so dev friendly upfront.. Imagine the nightmare around Android Studio and gradle...

Chapter 4

Rust’s central feature is ownership.

  • Each value in Rust has a variable that’s called its owner.
  • There can only be one owner at a time.
  • When the owner goes out of scope, the value will be dropped.

Good to know.