You’re not using ARC

ARC (Automatic Reference Counting) is a great addition to Objective-C, allowing for the automatic release of objects after they are no longer being used. After having come to Objective-C from C# earlier this year it seemed completely natural to me for it to be there; memory management had always been very good in .Net so I came with the expectation that the compiler would worry about memory management for me. This meant that when I learned Objective-C, I got completely used to using ARC.

But am I using ARC? I wasn’t writing any extra code that I wouldn’t have written normally. I’m not thinking any differently. ARC has effectively become so embedded into Objective-C that I would argue that now it seems like you’re using ‘extras’ when writing code with old school memory management.

When browsing for arguments for not using ARC I found that generally the consensus was that ARC does everything you could possibly need it to do (‘Use it. Do it today’) and the only real reason to not use it is if you are perfectly capable of writing good ‘old school’ code or if you need to support two/three year old versions of iOS/OSX. Even then, the suggestion was that you are only going to write better code if you use ARC.

I struggled to find any other strong arguments for not using ARC, because of the simplicity that it brings to Objective-C. One suggestion was that it would make older code harder to maintain, but at the end of the day it doesn’t – I have written code that integrates absolutely fine into my existing code because I can just set Xcode not to use ARC on specific files.

Ultimately I think that because ARC is such a standard thing to ‘use’ now we shouldn’t think that we are ‘using’ it any more. It should be accepted as a component of Objective-C rather than thinking of it as an ‘extra’ feature (even though, technically it is an addition Apple made to Clang).

N.B: ARC is great for learning and also terrible for learning. It is great because it makes Objective-C a hell of a lot easier to learn and if you are a beginner it makes code in general a lot simpler to understand. On the other hand, it is awful because it doesn’t teach memory management or garbage collection at all. Developers should have an understanding of where their objects are at any point in the event loop, and by having all of the release and retain calls in your code it is a lot easier to understand, but in theory ARC should mean that you don’t have to understand it anymore.


3 thoughts on “You’re not using ARC

  1. Pingback: Lessons from iOS Development #3: Let’s forget this | Programming Thomas

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s