JS Ext

Thursday, November 1, 2012

What is garbage collection?

When the iPhone 5 came out, there was a resurgence of the iOS vs Android debate.  In one of the comment sections of an article (I really have to stop reading the comments), an iPhone user argued that iOS is better because the Objective-C programs written use Automatic Reference Counting (ARC) instead of the "Garbage Collection" that Android uses.  As a Computer Scientist, my head almost blew up.

I know what the person was talking about, but it irritates me when it is used in arguments.  It may be nitpicking, but ARC is GC.  Garbage Collection means the developer doesn't have to explicitly delete any memory that they create.  It does not imply anything more than that.  Reference Counting is one implementation of Garbage Collection.  Mark-and-Sweep is another implementation.  The person was trying to argue ARC vs Mark-and-Sweep, but didn't know the term Mark-and-Sweep, or Generational Garbage Collection.  It was obvious the person didn't understand the changes in Java's Garbage Collection implementation since Java 1.1.  That is not unreasonable.  When teaching Garbage Collection algorithms, many courses stop at basic stop-the-world Mark-and-Sweep.  All the advances in Java's GC implementation are variations of Mark-and-Sweep.

My main problem with the comments in this thread was the person claimed ARC had no negatives while "Garbage Collection" had no positives.  The comments sounded like they came from a person that never had any formal Computer Science training and has never programmed for anything other an iOS.  In future posts, I will talk about some of the misconceptions around Garbage Collection and go over the long lists of pros and cons for each implementation.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.