5 ms·
> who in the fuck would write a garbage collector using garbage collected Rust? Rust is not garbage collected unless you explicitly opt into using Rc/Arc
by chiffaa 10mo ago
> who in the fuck would write a garbage collector using garbage collected Rust?
Rust is not garbage collected unless you explicitly opt into using Rc/Arc
- oconnor663 10mo agoI still wouldn't call it GC in that case. It's pretty much exactly the same as std::shared_ptr in C++, and we don't usually call that GC. I don't know about the academic definition, but I draw the line at a cycle collector. (So e.g. Python is GC'd, but Rust/C++/Swift are not.)
- cmrdporcupine 10mo agoI consider reference to be garbage collection, and so do most CS textbooks. However Rc/Arc/shared_ptr are GC facilities used (often sparingly) inside predominantly non-GC'd languages, so, yeah, I wouldn't say Rust "is" or "has" GC. It has facilities for coping with cleanup, both RAII and GC.
- gpm 10mo agoIf you count Rc/Arc as garbage collection you should count RAII + The Borrow Checker (i.e. all safe rust) as garbage collection too IMHO. It collects garbage just as automatically - it just does so extremely efficiently. That said I tend to count neither. Garbage collection to me suggests you have something going around collecting it, not just you detect you're done with something when you're done with it and deal with it yourself.