Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

AIUI, Swift uses reference counting, not fully-general GC. So, it's really not different from Rust from that POV, other than the fact that Rust can avoid the overhead of atomic refcount updates (or sometimes of reference counting at all) in many cases where Swift requires it. It also seems a bit silly to push for Swift on the backend when excellent and well-supported alternatives exist such as Rust, Go and others.


> AIUI, Swift uses reference counting, not fully-general GC. So, it's really not different from Rust from that POV, other than the fact that Rust can avoid the overhead of atomic refcount updates (or sometimes of reference counting at all) in many cases where Swift requires it.

No, ARC is a kind of GC. In particular, you have the same pausing behaviour as mark/sweep GC, because freeing any value might result in having to free arbitrarily many other values whose reference counts now go to zero.


ARC as in atomic reference counting? I mean, Rust literally has an Arc<> type!


> ARC as in atomic reference counting?

Automatic, I think, but yes.

> I mean, Rust literally has an Arc<> type!

Yes, but idiomatic Rust makes very limited use of it; if you do use an Arc in Rust you have visibility and control over when you unreference it. Whereas in idiomatic Swift you're doing unmanaged dereferences all over the place.

I mean, of course it's possible to implement garbage collection in your non-GC language. The difference between a GCed language and a non-GCed language is whether GC is implicit and pervasive, or explicit and manually controlled.


> Yes, but idiomatic Rust makes very limited use of it ...

This is hardly a positive for Swift; Rust still collects its garbage as much as Swift does; it just does so more efficiently by making use of compile-time lifetime analysis (RAII-like), in addition to the RC technique that Swift uses.


You were the one who was claiming "it's really not different from Rust from that POV". What you dismiss as "it just does so more efficiently" is the entirety of the difference between GC and non-GC languages; Swift is a GC language with everything that entails, and Rust is not.


Swift’s Arc is automatic reference counting. It’s implemented via atomic reference counting, as far as I know.

Rust’s Arc and Rc types are never applied automatically.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: