3 ms·
I think it's mostly targeted at C or C++ users. Swift is garbage collected.
by Zababa 5y ago
I think it's mostly targeted at C or C++ users. Swift is garbage collected.
- sgt 5y agoIncorrect, Swift is not garbage collected. It uses reference counting. Read more here: https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html https://docs.swift.org/swift-book/LanguageGuide/AutomaticRef... As for C and C++, yes, of course. I meant "everyone else" as in the trendy new languages.
- saagarjha 5y agoReference counting is technically a form of garbage collection, FYI.
- sgt 5y agoReference counting deals with operations that have constant time, which I think puts it in a different category than what people normally view as GC.
- Zababa 5y agoI'm not sure that's true. Python mainly uses RC, yet most people think of Python as GC'd. I would argue that most people think that GC == automatic memory management.
- sgt 5y agoYes, I think you are correct actually.
- kaba0 5y agoAnd has a different tradeoff, due to atomic operations being needed for objects shared between threads (and of course, circular references). But no matter what, it is literally a GC algorithm, described in every book about GCs.
- zozbot234 5y agoSwift uses ARC (atomic reference counting) which differs from tracing GC. C++ and Rust have similar features but can avoid the overhead of ARC in many cases.
- Zababa 5y agoI know ARC is different from tracing GC, I just don't like how some people try to sell Swift as not garbage collected when it is. Python mainly uses RC, and no one would image calling Python not garbage collected. Calling Swift not garbage collected is a marketing trick, saying they make different tradeoffs compared to tracing GCs is true.
- FpUser 5y agoI have big and complex server in C++. Not a single explicit memory related call in it. STL does wonders in this department.