Hacker News new | ask | show | jobs
by djwatson24 2003 days ago
Cool to see explicit annotations for how to make rc fast when you have access to the ir. But doesn’t solve some major issues, like cycle collection:

“ In practice, mutable references are the main way to con- struct cyclic data. Since mutable references are uncommon in our setting, we leave the responsibility to the programmer to break cycles by explicitly clearing a reference cell that may be part of a cycle. ”

2 comments

Always a catch with these zero-overhead refcounting schemes. If the programmer has to use some equivalent to weakrefs then how is this an improvement over existing schemes? The possibility of cyclic garbage to accumulate is a very big drawback in many applications.
const is really popular in JS... (i.e. could they surreptitiously be taking on Orinoco?)
I don’t think const or non const is the main issue- some data structures just require cycles like graphs or circular linked lists.
I don't disagree, but I also suspect that a very large number of real world JavaScript applications have few to no application-induced cycles. I might even go further and say this extends beyond JavaScript--the most common reason I even define recursive data structures in a language like Rust is for AST-like data that almost invariably forms a tree.
I supposed you could construct as dynamic and then make it constant? I wonder why that feature isn't seen in common languages, even though I know it sounds crazy.
Clojure has transient mutable collections that are designed to become persistent once "complete". [1] Some systems have made use of using reference count of one (unique owner) as permission to mutate, something that TFA generalizes as memory reuse.

1: https://clojure.org/reference/transients