Hacker News new | ask | show | jobs
by dave4420 689 days ago
A variant of option 4 is to keep track of references you know cannot possibly be shared, and update those by mutation. Compared to reference counting, it misses some opportunities for mutation, but avoids the false sharing.

I think Roc is doing this.

3 comments

Came here to say this! Last I heard, the Roc folks were still curious to see whether this bet pays off for most/all codebases.
To what extent is this already being done by other functional blanguages that have CoW mutability? This seems like a legal compiler optimization to make in most cases no?
Clean has been doing this for nearly as long as people have been using monads, but it never got the attention Haskell did, which I think is quite unfortunate. Rather than implictly keeping track of references, uniqueness types are marked explicitly to inform that their values cannot be aliased. They can also be used with monads to improve ergonomics a bit.

Granule has uniqueness types like Clean built onto a linear type system, which offers some additional advantages.

Is Clean being used anywhere? Last time I looked at it was 1999 and, while cool, I haven't ever heard of anyone using it.
jq does this. But at the jq language level it looks like mutation creates new values without mutating the old ones.