←back to thread

239 points ivankra | 7 comments | | HN request time: 0.939s | source | bottom
1. MattRix ◴[] No.45945525[source]
Rust is not garbage collected though.
replies(1): >>45945745 #
2. chiffaa ◴[] No.45945530[source]
> 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

replies(2): >>45945727 #>>45946167 #
3. oconnor663 ◴[] No.45945727[source]
I 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.)
replies(1): >>45945835 #
4. vampirex ◴[] No.45945745[source]
Yes, but safe Rust enforces strict borrow checking with tracing, reference counting, etc. which would be inefficient for GC implementation.
replies(1): >>45945760 #
5. LtdJorge ◴[] No.45945760{3}[source]
What tracing?
6. cmrdporcupine ◴[] No.45945835{3}[source]
I 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.
7. gpm ◴[] No.45946167[source]
If 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.