Dynamic Borrow-Checking in a Toy Programming Language: Implementing Rust-like Memory Safety Without Static Types
By
jamii
1mo ago· 34 min readenInsight
100/100
Golden Brown
Bagelometer↗
If you only eat one bagel today, this is the bagel.
Score100TypeanalysisSentimentneutral
Summary
This article presents a demonstration of a toy programming language that implements borrow-checking without static type-checking. The language features dynamic typing, inline values, stack allocation, interior pointers, single ownership, and a limited form of borrowing that is less expressive than Rust but more expressive than second-class references. The key innovation is performing borrow-checking dynamically rather than statically, achieving this efficiently with useful error messages. The author explores type-system styles similar to Julia and Zig, focusing on how borrow-checking can be implemented in dynamically-typed languages.
Key quotes
· 3 pulledThis is a demo of a toy language with dynamic typing, inline values, stack allocation, interior pointers, single ownership, and a limited form of borrowing - less expressive than rust, but much more expressive than second-class references
Since there is no static typing the borrows must be checked dynamically. The interesting part of the demo is that we can do that fairly cheaply and with useful error messages
I'm exploring a style of type-system exemplified by julia and zig. Both languages start with a dynamic type system
This is a demo of a toy language with dynamic typing, inline values, stack allocation, interior pointers, single ownership, and a limited form of borrowing - less expressive than rust, but much more expressive than second-class references (eg we can expre
