4 ms·
I don't think he was defending reference counting as much as trying to explain that garbage collection is probably never going to work satisfactorily with an un
by quux 15y ago
I don't think he was defending reference counting as much as trying to explain that garbage collection is probably never going to work satisfactorily with an unmanaged language like Objective-C. Automatic Reference Counting is probably as good as we're going to get without a managed version of Objective-C.
- nknight 15y agoThis distinction between "reference counting" and "garbage collection" is either an Apple or Gruber invention. I've never heard anyone try to distinguish cleanly between the two before. Use of (automatic) reference counting is not new (see, for obvious example, Python), and is certainly being used as a form of garbage collection. There are many forms/strategies of garbage collection, reference counting is one of them. Trying to argue that we're never going to have "garbage collection" on iOS is utterly bizarre -- it's being added in iOS 5! It's just taking a different form.
- schrototo 15y agoWell, I think the generally agreed upon meaning of "garbage collection" is something along the lines of "automatic memory management at runtime" (garbage piles up and gets collected) while "automatic reference counting" is "automatic memory management at compile time" (there's nothing to collect since nothing's gonna build up). All those terms sometimes get used differently in different contexts sometimes, but I think that's what's usually meant by them.
- nknight 15y agoYou're describing the difference between deterministic and non-deterministic garbage collection, not between garbage collection and some other concept. Even non-deterministic tracing garbage collectors may make use of reference counting. Some interesting references: http://en.wikipedia.org/wiki/Garbage_collection_(computer_science) http://en.wikipedia.org/wiki/Garbage_collection_(computer_sc... http://www.research.ibm.com/people/d/dfb/papers/Bacon01Concurrent.pdf http://www.research.ibm.com/people/d/dfb/papers/Bacon01Concu... http://www.google.com/search?q=garbage%20collection%20reference%20counting http://www.google.com/search?q=garbage%20collection%20refere...
- wtallis 15y agoYou have to understand the history in order to understand why there's a distinction. If it weren't for all the Java programmers who've tried to get rich off the App Store in the past several years, there wouldn't be much need for a distinction. However, too many of the Java programmers that have been jumping on the Objective-C bandwagon have never before had to give any consideration to memory management. Thus they had trouble learning to use the Cocoa manual explicit reference counting paradigm, which requires the application programmer to know where to make calls to -retain and -release. This requirement that the application programmer participate in memory management contributes more to the distinction than the fact that the Cocoa reference counting scheme imposes less runtime overhead than most robust garbage collectors of the sort used by Java or Python. The new Automatic Reference Counting used by Cocoa is still different from traditional garbage collectors, because it is implemented without imposing any more runtime overhead than the manual scheme. ARC is essentially a preprocessor phase that infers (based on coding conventions) where to place the calls to -retain and -release. None of the complex logic for tracking the lifetime of an object is done at runtime. It's done at compile time, if at all. (ARC differs from full-fledged robust garbage collectors like what Java has in that ARC can't handle situations like cycles in the object graph. Handling those cycles is one of the main things that makes writing a high-performance Java-like GC non-trivial, but ARC simply chooses to not be that automatic.)
- nknight 15y agoSo I'm getting a ton of downvotes because I called an Apple-invented distinction an Apple-invented distinction? Did I just step into the twilight zone?
- wtallis 15y agoApple didn't invent the difference. It just wasn't that important until it applied to Apple. That difference, and the consequences of it, are one of the most important distinctions between Apple's mobile operating system and it's competitors. What ten years ago may have seemed like trivial academic pedantry may now be a significant competitive advantage or disadvantage in a lucrative market.