Has there ever been a discussion about the feasibility of tracking references for values, statically determining if an update can safely be made in-place if there are no other references?
As an experiment, I wrote a quick and dirty implementation of QuickSort, while performing reference counting at runtime using JS FFI hacks. I’m not sure if there’s a way to write an ergonomic library without compiler support for this, but the code is here in case it’s interesting - Anupam Jain / purescript-linear-experiments · GitLab
Incidentally I quickly ran into the problem with PureScript not supporting mutual tail recursion optimisation, and sorting large arrays blows the stack.
From the same Roc talk - here are some things to contribute to Roc being fast.
Accurate (and efficient!) reference counting relies on a lot of support from the runtime, so it isn’t possible for JavaScript. There’s nothing PureScript can do to work around it, especially with all the FFI where you don’t know what happens to those references.