Back to search

University of Waterloo

Linear Scala is All You Need for Safe Static Memory and Alias Management

Abstract

dc:description.abstract

Rust has become one of the most popular languages for systems programming. This popularity is largely driven by Rust's ability to provide safe static memory management without garbage collection, eliminating GC-induced pauses and runtime overhead that can be difficult to predict and control. In addition, Rust enforces alias and mutability control through its ownership and borrowing discipline, enabling features such as fearless concurrency and stronger compiler optimizations while preserving memory safety. Scala Native brings Scala to systems-level targets by compiling to LLVM IR. However, it still relies on third-party garbage collectors for memory management and does not provide Rust-style static guarantees for safe memory management, aliasing, and mutability control. This thesis presents imem, a library that brings Rust-inspired ownership and borrow checking to Scala, and Scinear, a minimal compiler plugin that adds linear types to Scala and integrates them with capture checking and polymorphism. imem proves that, given Scala's type system, linearity is the only missing ingredient needed to implement most of Rust's ownership and borrowing discipline as a library rather than a dedicated language feature. imem provides linear Box values and immutable and mutable references, enforces ownership rules, and statically controls aliasing and mutability, following the Stacked Borrows model. In addition, imem offers optional runtime verification to detect potential safety violations when users apply workarounds to the static rules. To demonstrate practicality, the thesis develops a safe linked-list case study and compares imem against Rust, vanilla Scala, and linear Scala. The evaluation shows that imem matches Rust's level of expressiveness, so it can support list operations and iterators alongside statically enforcing ownership rules and controlling mutability.

Degree

thesis:*
Grantor dc:publisher
University of Waterloo
Year dc:date.issued
2026

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Pashaeehir, Amirhossein

Subjects

dc:subject × 7

Rights

Language dc:language.iso
en

Identifiers

dc:identifier.*
Handle dc:identifier.uri
https://hdl.handle.net/10012/22982

Chain of custody

source
Harvested from
University of Waterloo
Base URL
dspacemainprd01.lib.uwaterloo.ca/server/oai/request
Last updated
2026-11-19
Source record
OAI-PMH GetRecord
citation

Pashaeehir, Amirhossein. Linear Scala is All You Need for Safe Static Memory and Alias Management. University of Waterloo, 2026. https://hdl.handle.net/10012/22982