Rust manual on References and Borrowing.

Stackoverflow 2020 survey:

Stackoverflow 2023 survey:

However Rust went down:

Sources

POA

  • Familiarise myself with Rust ✅ 2024-03-11

    • Understand References and Borrowing ✅ 2024-03-11
    • helloworld app? ✅ 2024-03-11
    • Should I include learning Rust into it? Like how long it is taking me to learn it? How does the visualisation help? ✅ 2024-03-11
  • Familiarise myself with Parsing ✅ 2024-03-11

    • Go through the RustViz code. ✅ 2024-03-11
    • Maybe try to do a minimal parser? ✅ 2024-03-11
  • Why Rust? ✅ 2024-03-11

  • What are the benefits of References and Borrowing? ✅ 2024-03-11

  • How is Rust more efficient? Is it? ✅ 2024-03-11

  • Can I do a minimal version of this? ✅ 2024-03-11

  • Come up with title ✅ 2024-03-11 Rust Visualisation?

  • Problem definition? ✅ 2024-03-11

Rust achieves memory safety without the need for a garbage collector. They use an ownership and borrowing system instead. This is quite complex. Therefore, being able to visualise them should help the developer, as they normally have to track it mentally.

The visualisations should make the static events visible, and subsequent state changes. RustViz focus on the static semantics of Rust, not run-time behaviour (like Python Tutor). It is similar to TypeTool, but focuses on borrow checking rather than type checking.

  • Have sources. ✅ 2024-03-11

  • Explain my approach? ✅ 2024-03-11 Learn Rust + implement a basic parser (how hard could it be?) -> get analysis?

  • Evaluate. ✅ 2024-03-11

TODO

Problem statement, what the project is about and the approach.

Think about programming languages, is Rust a good idea?

Languages that are easy to write parser in, what is the Rust parser written in?

Look into good Rust analyser, what is a good parser generator for Rust?

Get in touch with Rust people (Arthur!)

How do we go from here? What do we do with the output from the parser?

RustViz

Generates interactive visualisations from simple Rust programs, to better understand the Rust Lifetime and Borrowing mechanism.

It generates a SVG file that integrate with mdbook (a Rust utility to create modern online books from Markdown files) to render interactive visualisations of ownership and borrowing.

The draft paper.

You have to annotate the Rust program.

To run:

~/rustviz/rustviz_mdbook$ ./view_examples.sh

With this tool, we need to define all possible owners in a main.rs file (Resource Access Points or RAPs):

/*--- BEGIN Variable Definitions ---
Owner x; Owner y;
Function String::from();
--- END Variable Definitions ---*/

We then have to annotate the code with ExternalEvents that describe move, borrow, and drop semantics in Rust, we do:

  1. Move of resource from String::from() to x
  2. Move of resource from y to x
  3. Drop of resource binded to x
  4. Drop of resource binded to y
/* --- BEGIN Variable Definitions ---
Owner x; Owner y;
Function String::from();
 --- END Variable Definitions --- */
fn main() {
    let x = String::from("hello"); // !{ Move(String::from()->x) }
    let y = x; // !{ Move(x->y) }
    println!("{}", y); // print to stdout!
} /* !{
    GoOutOfScope(x),
    GoOutOfScope(y)
} */

Each Event is defined on the line where it occurs and within delimiters !{ and }.

Limitations

Some features are still being built. As of now, we are limited to:

  • No branching logic
  • No looping
  • No explicit lifetime annotation