All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Contravariant lifetimes and garbage collection: Inside Nova's Rust-based JavaScript engine

By

aapoalas

4mo ago· 21 min readenInsight

Summary

This article from the Nova blog discusses the contrarian approach to garbage collection (GC) in the Nova JavaScript engine, which is written in Rust. The author explains how they model GC using the Rust borrow checker with contravariant lifetimes, a novel approach that goes against typical GC design patterns. The piece covers the philosophical underpinnings of this model, the practical implementation challenges, and the trade-offs involved in building a 100,000+ line Rust JavaScript engine that uses this unconventional GC strategy. The author reflects on both the excellence and awfulness of this approach, particularly how it manages to explain garbage collected handles in a way the borrow checker can understand.

Key quotes

· 3 pulled
It is excellent in that it manages to explain garbage collected handles in such a way that the borrow checker can check them.
Previously on this blog I've written about how Nova JavaScript engine models garbage collection using the Rust borrow checker.
I have, together with a lot of contributors, written a JavaScript engine encompassing more than 100,000 lines of Rust using this model which is equal parts excellent and awful.
Snippet from the RSS feed
Modeling unrooted handles to garbage collected data using contravariant lifetimes.

You might also wanna read