Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I personally don't know much about iOS 5, but it seems like with automatic reference counting (ARC), you get rid of much of the memory management issues of the previous operating systems.

So is it better to target iOS5 (and create apps that can only run on the newest iOS devices), or is it better for her to target iOS 4 or even iOS 3, so she understands the fundamentals of memory management in Objective-C? Are there any important aspects of iOS development that she might miss out on by jumping into iOS 5?

share|improve this question
    
What does your friend want to do, once she's learned one version? Without knowing that, we can't give advice. –  David Thornley Dec 8 '11 at 20:56
    
I think the decision should be based solely on whether or not your friend wants to make programs for older devices. –  Robert Harvey Dec 8 '11 at 21:10
    
What X should I learn is off-topic, but I think this question is really more about targeting, and as such it's a pretty straight-forward question that can be answered with science. –  user8 Dec 8 '11 at 21:26
    
She's looking to make apps for a general audience, on a hobbyist level, so we didn't look too closely at the current device market share. I think also she's afraid that if she goes with ARC she won't be able to deal with the nitty-gritty of how m.m. used to work. Since I started with iOS 3, I have the fundamentals of that already, which she's afraid of missing out on. –  Apophenia Overload Dec 8 '11 at 22:23
    
@ApopheniaOverload Ah, thanks for clarifying: I've adjusted your question again somewhat to focus on the memory management aspect of the choice instead of the overall question. If there's anything you think is missing, feel free to revise it further. –  user8 Dec 8 '11 at 23:06

3 Answers 3

up vote 15 down vote accepted

Worrying about memory management

ARC is a godsend: it doesn't solve every problem, but it's much better than having to do it all yourself or the short detour into garbage collection with Mac OS X.

There are two things to keep in mind with it:

  • it's a compiler feature: Xcode provides ARC support for building to iOS 4 targets1.
  • It's optional, even targeting iOS 5. If you want to learn manual reference counting (MRC) just to make extra sure you know it, you can do it even targeting iOS 5.

But ARC doesn't take away the ability to understand how memory management works, it just removes the tedium of having to declare release and retain everywhere. Justin on Stack Overflow gave a good summary of the difference between ARC and manual reference counting (MRC):

If you don't want to learn MRC, then you may want to first try ARC. A lot of people struggle with, or try to ignore common practices of MRC (example: I've introduced a number of objc devs to the static analyzer). If you want to avoid those issues, ARC will allow you to postpone your understanding; you cannot write nontrivial objc programs without understanding reference counting and object lifetimes and relationships, whether MRC, ARC, or GC. ARC and GC simply remove the implementation from your sources and do the right thing in most cases. With ARC and GC, you will still need to give some guidance.

Beyond whether or not you should use ARC, you ought to consider support for the OS version: does it really make sense to focus on version-specific features (like zeroing weak references) when there aren't a whole lot of people using that version?

Or worse yet, if everyone's using iOS 3, how long do you have to wait until you can even start to use ARC?

This comes down to two things: device support and market share.

Device support

Thankfully, one of the benefits to developers with respect to iOS development is that the latest version of the software runs on older devices; generally going back at least 2 years.

So if you want to target iOS 5, you'll be able to target the following devices:

  • iPhone 4S (released October 2011)
  • iPad 2 (released March 2011)
  • iPod touch (4th generation, released September 2009)
  • iPhone 4 (released June 2010)
  • iPad (released April 2010)
  • iPod touch (3rd generation, released September 2009)
  • iPhone 3G S (released June 2009)

Which is a large set of options. If you target iOS 4.2, you can hit every device since iPhone 3G was released back in June 2008.

Market share

Which comes to the other question: should one spend time learning anything other than iOS 5 SDK: it depends on what you want to do.

If you want to just focus on the latest and greatest, use all the neat features available in the latest SDK, and damn market share (for now): by all means go for it.

If you want to maximize market share now, I'd hold off for a few more months.

Marco Arment, the creator of Instapaper (a really popular iOS app), publishes his usage stats from time to time and just released the latest report a few days ago. In it, he notes that iOS 5 has a 45.1/48% iPad/iPhone market share, while iOS 4.2 (needed for CDMA iPhone 4s that haven't upgraded to iOS 5 yet) has a 97/97.2% market share.

Generally, hitting 97% of the potential market is "close enough": I've seen it as a rule of thumb not just for iOS development, but for web development as well.

But one thing to consider is how long of a development cycle you're going to have. If you're not planning on launching for a few months, iOS 5 is not a bad choice, even if you're trying to hit a large portion of the potential market share.

iOS users tend to upgrade much quicker than on other platforms, for a variety of reasons, and there's no reason to believe the upgrade from iOS 4.x to iOS 5 will trend any differently. If you take iOS 4.2's market share as a baseline, it was only released a year ago. It's not unreasonable to assume that October of next year iOS 5 will be well into the 90% range.

Conclusion

Don't worry about memory management too much: ARC is a great convenience, but it's not a huge paradigm shift from earlier versions. Instead, worry about the other features and support issues. If you're launching today and need to hit the largest market share possible, target iOS 4 and consider using MRC. Otherwise, target iOS 5 and consider using ARC.

1caveat: you lose out on some features if you need to target < iOS 5, like zeroing weak references. If you want to go whole-hog into ARC, you're probably better off targeting iOS 5.

share|improve this answer
1  
This is a really great response! We both appreciate how you've hit multiple aspects of this issue. –  Apophenia Overload Dec 8 '11 at 22:25
    
Cheers for the balanced perspective –  Daniel Skinner Jul 20 '12 at 10:11

Around 500,000 apps were written without ARC, many by kids. Also many millions of potential app users with devices not (yet) on iOS 5. Many developers are waiting for that number to be a smaller fraction of their potential market share before jumping strictly to iOS 5. And experience with manual memory management might be very helpful when tracking down bugs in future apps that use ARC.

So at this point in time, I might recommend learning both, using MRC for today's apps and ARC for future apps.

share|improve this answer

1) as a serious programmer, you cannot miss full comprehension of MRC.

2) in certain situation (CF...) You must know it.

3) ARC is very fine and useful. (I came from malloc / free BUT appreciate it..)

4) Apple directions from last wwdc2012 (I were there..) was USE ARC! Period! Indeed all new code is written for ARC.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.