Skip to content

Conversation

benw
Copy link

@benw benw commented Aug 29, 2025

Hi, this video is an introduction to borrowed references and ownership that I hope you'll find sufficiently novel. It avoids using any Rust syntax, instead walking through the invention of a thought-experiment language based on C. It's based on Aria Desire's way of explaining ownership. The basic structure is:

  • Pointers are evil, remove all pointers from C
  • File example: It's still possible to cause use-after-close on a file :(
  • Invent move-only types :)
  • Now the write function consumes the file :(
  • Invent borrowing for function parameters :)
  • Array example - push works great, but no way to get a pointer to an element in-place :(
  • Invent regions so we can return a borrowed reference from the get function :)
  • Can't borrow references to two array elements :(
  • Invent shared references :)
  • Mutable xor shared - accidentally thread-safe 🎉

@benw
Copy link
Author

benw commented Aug 29, 2025

I'm wondering if the link text should instead be "A novel introduction to ownership and borrowing" or something like that, very happy to be guided by you. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant