by adwn · 4y ago · 0 comments
That's why the entire approach is flawed: They didn't study "Rust + GC", but effectively created a new language. See [1] for more details.
Personally, as someone who uses Rust professionally, I believe optional GC would be a great addition to Rust! The compiler would provide support for GC, and the actual GC runtimes would be library-based, similar to how async/await is handled. However, this GC would merely replace Arc/Rc, not Mutex/RefCell/Cell.
[1] https://users.rust-lang.org/t/bronze-gc-and-aliasing-problem...
And I think Rust would be a much better target language for such a system than C++ was. For example, one of the interesting problems was that the .NET GC is compacting — it will move objects around to improve cache locality and simplify the allocation algorithm. To interact with ordinary C++ code, you need native pointers into GC’d objects. But it was only safe to take such a pointer while you told the GC to temporarily “pin” the object in memory, otherwise, your pointer could be randomly invalidated. Forgetting that step was a very evil source of nondeterministic memory bugs. It’s not hard to see how the borrow checker would help there.
Much easier than dealing with P/Invoke declarations or dealing with COM over RCW/CCW layer.