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

dc.contributor.authorPashaeehir, Amirhossein
dc.date.accessioned2026-03-30T19:13:23Z
dc.date.available2026-03-30T19:13:23Z
dc.date.issued2026-03-30
dc.date.submitted2026-03-20
dc.description.abstractRust 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.
dc.identifier.urihttps://hdl.handle.net/10012/22982
dc.language.isoen
dc.pendingfalse
dc.publisherUniversity of Waterlooen
dc.relation.urihttps://github.com/amsen20/imem
dc.relation.urihttps://github.com/amsen20/scinear
dc.subjectScala
dc.subjectProgramming Languages
dc.subjectStatic Memory Management
dc.subjectAlias Control
dc.subjectOwnership and borrowing
dc.subjectLinear and affine types
dc.subjectCompiler
dc.titleLinear Scala is All You Need for Safe Static Memory and Alias Management
dc.typeMaster Thesis
uws-etd.degreeMaster of Mathematics
uws-etd.degree.departmentDavid R. Cheriton School of Computer Science
uws-etd.degree.disciplineComputer Science
uws-etd.degree.grantorUniversity of Waterlooen
uws-etd.embargo.terms0
uws.contributor.advisorLhoták, Ondřej
uws.contributor.affiliation1Faculty of Mathematics
uws.peerReviewStatusUnrevieweden
uws.published.cityWaterlooen
uws.published.countryCanadaen
uws.published.provinceOntarioen
uws.scholarLevelGraduateen
uws.typeOfResourceTexten

Files

Original bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
Pashaeehir_Amirhossein.pdf
Size:
1.15 MB
Format:
Adobe Portable Document Format

License bundle

Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
license.txt
Size:
6.4 KB
Format:
Item-specific license agreed upon to submission
Description: