System Capybara: Capture Tracking for Ownership and Borrowing
Ownership and borrowing principles are powerful tools for preventing unintended aliasing, enabling safe memory management, data-race-free concurrency, and more. These principles, popularized by Rust, are often seen as too rigid to be integrated into mainstream languages like Scala without disrupting existing codebases.
System Capybara introduces flexible and expressive ownership tracking to Scala by extending capture checking, a recently introduced system for effect and capability tracking. It enriches capture checking with alias prevention guarantees, enabling fine-grained control over exclusive resources such as mutable buffers and file handles—while staying lightweight and flexible.
The talk presents System Capybara in three parts: (1) a brief overview of the problem and background; (2) a quick walkthrough of how capture checking can serve as a foundation for alias tracking; and (3) an introduction to System Capybara’s key ideas. This part is interactive, with examples presented in Cavia, a prototype compiler that implements System Capybara in a Scala-like language.