Correct me if I’m wrong, but I believe this is an alternative way to describe a system that is equivalent to copy on write, but with ahead of time analysis on reference counting, which means we can eliminate most of reference counting. We have this kind of analysis is already done in reference counted languages like Swift which also do copy on write.
It's not ARC, and not reference counting at all, but closer to an idea that has become quite popular in game development (because it's trivial to implement, doesn't need compiler support, and works in any language that has indexable arrays):
(disclaimer: I only wrote a blog post about it, that idea is much older and probably has been re-invented many times over since the first computers were built)
Essentially "non-owning weak references with spatial and temporal memory safety".
What is similar to ARC though is that moving that stuff into the language lets the compiler remove redundant handle-to-pointer conversions, similar to how with ARC the compiler can remove redundant refcounting operations.
They don't seem to be quite zero cost though when applied to the whole program, because they require changes to the allocator to ensure the generations are never overwritten by user data.
If you store them inline with the program data for max speed(tm) you need to ensure that e.g. after 2 2kb chunks are deleted, you don't overwrite them with a 4kb chunk, because that would trample over a generation.
If you do keep the generations inline and rely on a statistical approach, you have to be very careful to never generate "common numbers" like 0 as a generation because then it's extremely likely there will be a collision.
It'd a hard problem and I'm quite curious how all the edge cases are handled.
Maybe Vale's "regions" are per-type (essentially arrays)? That way a specific memory location would only ever be used for that same type (== same size in memory) until the whole region is destroyed.
iOS is getting a 'typed allocator' which seems to work similar:
Yeah typed allocator would be my guess but those aren't zero cost either. They increase memory usage since if your program allocate an array of 100 ints, delete them, and then allocate an array of 100 floats, unless you allocate more ints on the heap that memory isn't getting reused.
I didn't understand that blog post very well, but it made me think of "generational arenas"[0], and I'm curious how they compare? Generational arenas sound similar because they involve passing an index around instead of a pointer, are designed to handle many small self referencing "objects", and are popular in games, so in my mind they seemed similar.
This is not a reference counted system, but you manually free the memory. However, the references are safe to use in the sense that they can detect when the object they are referring to, is deleted.