Category Archives: development

Lessons in Rust: Part 1

I watched some videos today and here are some notes I took:

  • A function not ending in a semicolon being a expression versus a statement is odd.
  • A function having a return statement can end in semicolon and be an expression.
  • Stack is LIFO. Stack can only hold data of a fixed size. A double quoted string is fixed length. A String::from is dynamic length and stored on the Heap.
  • When a value is put in the Heap, the Heap is searched for space large enough to hold the element (out of order, versus the Stack always in LIFO order).
  • All Heap values have a ‘pointer’ value in the Stack.
  • When a variable is passed into a function the function takes ‘ownership’ of the variable. Three ways to ‘fix’ this issue:
    • Clone traight, potentially performance impacting.
    • Copy traight (which requires Clone traight). Copy is explicit and Clone is implicit (in the way its called .clone() versus not).
    • Use a READ_ONLY_REFERENCE of a variable using the “&” on the parameter name.
  • With variables to functions, the MUTABLE_REFERENCE can only be applied once, versus the READ_ONLY_REFERENCE which can have many.
  • Lifetimes
    • Begin with a single quote.
    • Are only relevant for references.
    • They dont change the lifetimes of the parameters.
    • They can be inferred

I found these videos interesting:

Getting Rusty

With the continued impressive industry reception and excitement around Rust,  I think it is time I jump and and see what all the hub·bub is about.

After watching a few starter videos, and reading documentation, here are some of my  initial thoughts:

  • Statically compilied versus interpreted (like my dear Python language.)
  • Performance is almost hard to believe compared to some other languages doing like processes.
  • Memory-safety and thread-safety design ground up sounds like a dream come true for those of us who have fought those demons.
  • Creates is to Rust what Pip is to Python.
  • A lot of people seem to have issues (or at least a hard time understanding) what Rust’s Borrowing is all about.
  • None over Null data type is interesting for a hard core C# developer.
  • The Crab logo is odd, as is the entire “cRUSTaceans” name used by those who adore Rust.
  • Linux kernel is going to have Rust support with v6.1. I never thought I would ever see anything but C in Linux kernel code.
  • Redox is an entire operation system written in Rust

I think the first thing I am going to try to tackle with Rust is media file processing for Roadie. Perhaps re-write Inspector in Rust.

Wish me luck getting Rusty!