3 ms·
Swift doesn't have lifetimes either, as it's garbage collected via reference counting.
by pcwalton 10y ago
Swift doesn't have lifetimes either, as it's garbage collected via reference counting.
- stcredzero 10y agoSwift isn't garbage collected. ARC is not GC. It's actually a form of manual memory management, with lots of help from the compiler. The way you structure your program does give particular objects a particular lifetime. https://news.ycombinator.com/item?id=7813598 https://news.ycombinator.com/item?id=7813598
- pcwalton 10y agoReference counting is a form of garbage collection [1] [2], as I've explained numerous times before. It has been considered a form of GC since the original papers in the 1960s and I see no reason to revisit that definition now. To track the lifetimes of objects, Swift programs perform operations (reference count manipulation) at runtime. That's because the Swift compiler does not know the static lifetimes of objects, unlike Rust. It can optimize away some reference count traffic, but this doesn't change the basic system: semantically, all objects are reference counted. [1]: https://en.m.wikipedia.org/wiki/Reference_counting https://en.m.wikipedia.org/wiki/Reference_counting [2]: http://www.memorymanagement.org/glossary/a.html#term-automatic-memory-management http://www.memorymanagement.org/glossary/a.html#term-automat...