120 points · by maplant · 1y ago · 63 comments
Essentially, it’s a refinement of Bacon-Rajan’s cycle collector (sequential) that does not require auxiliary heap memory and handles failures when tracing complex object graphs because it uses a breadth-first technique that fundamentally prevents stack overflow scenarios.
What's particularly compelling is the Rust implementation, which weaves the type system and borrow checker into the algorithm's design. When dealing with garbage cycles, the algorithm doesn't just match current Rust GC alternatives, it outperforms them.
I linked a preprint of the paper that presents it and that we’ve got recently accepted at SAC2025 because it details both the theory and the Rust implementation. The paper also includes the link to the repository, but it makes sense to report it here https://github.com/frengor/rust-cc
I don't think you'd find a GC library to be useful to most developers if it required that. For those who might need it, it can be useful but for everyone else you're just paying for unnecessary pain.
I found the syntax-rules implementation but didn't really see any part of syntax-case. Did you mean you support syntax-transformers in general (together with what looks like a very nice syntax-rules implementation), and not syntax-case in particular?
My email is on my website, if you have any other questions feel free to shoot me an email.
It has always been an option if you want it, though.
Nice thing about it in Rust too is that you can get the benefit of the garbage collector, but only and exactly where you want it, rather than it being used for the entire language.
There are known real world data structures that are sometimes useful (though I've never encountered a need to use them) where because you have circular references to things you have to use a mark and sweep garbage collector. If you happen to need such a thing in your Rust code than this will be useful.
For a few applications, though (e.g. a JavaScript VM, or something that deals with complex graph structures with unpredictable lifetimes), a GC is a lifesaver. Even in these applications, most of the data structures won't need GC pointers. Rust has a few GCs at hand, and lets you opt-in to GC specific pointers. In theory, this means that the GC can be extremely fast, because the graphs it needs to walk will be much smaller than in languages with a general-purpose GC. The cost, of course, is that you, as a developer, need to pay attention to what needs a GC and what doesn't.
Tracing GCs can do most of the work completely independently of the user code, and in parallel. Also, only live objects are touched, which can be also beneficial for certain kinds of applications.
Some very rough analogies:
C++ : Rust
unique_ptr : Box
shared_ptr : Rc or Arc
references : referencesThe benefit is that it makes Rust much easier to maintain and port to new architectures, and much more polyvalent, e.g. you can use Rust on true embedded, by opposition to most other modern languages, and presumably more future-proof. The drawback is that you, as a developer, need to pick a runtime.
[1] In truth, there's still a runtime, but it's really tiny.
This is why there are various "de facto standard" crates for basic things like regexes or error handling that would be built-in in other languages.
E.g. heavily recursive data structures may not be a best fit (also not the best fit for the CPU).
Rust has definitely grown out its own style, which is more of a "strongly typed FP with local-scoped imperative parts", elegantly combining ML's strengths with C/C++-style performant patterns.
I found "loop" pretty horrible.
That's indeed one of the major advantages of Rust but it's not the only reason people like the language. Just to give an example, you can write concurrent code without ever worrying that you accidentally failed to protect something with a mutex; whether some code is thread-safe or not is encoded in the type system and violating thread safety is a compiler error. This is a huge advantage that has little to do with lack of GC.