Thursday, January 7, 2010

A Theory: Why the iPhone doesn't allow background applications

The lack of support for background applications on the iPhone drives me crazy since it prevents a number of very useful apps from being deployed on it. The one I miss most from my BlackBerry is Google Talk for instant messaging. Today I was thinking about why Apple would disallow a basic feature that every other modern OS supports. I can think of two complementary reasons.

The first has to do with user interface. Most users don't understand the very concept of "background applications". I'm not sure I've ever seen a really great UI for managing running processes on a desktop OS let alone a mobile one. Since most applications don't need the feature anyway my guess is that Apple just punted on it.

The second reason is more technical. Currently the iPhone only supports application development using Objective-C. More notable is that it is Objective-C without garbage collection. This means that each developer is responsible for his or her own memory management. All but the most egotistical of developers would admit that managing memory is a difficult problem and most of us do a bad job at it. If allowed on the iPhone many of our poorly written applications would run in the background eating away at the memory and slowing the phone down until the frustrated user reboots it. Foreground-only applications means that won't happen since the application will be destroyed after just a few seconds or minutes. As a result I suspect that most iPhone developers do little to no memory management what so ever.

iPhone OS will have to support background applications eventually and my prediction is that it will arrive on the same day that garbage collection does.

2 comments:

Dennis said...

Personally, I think Apple wants to do background apps in a different way than other mobile OSes. For example, instead of running the entire app to stream some music in the background, they might allow you to define a helper service that connects up to your server and plays the music. For periodic tasks, they could allow you to set timers and run limited tasks.

As far as GC goes, they already have a mechanism for killing apps when memory runs low. I would suspect that whatever they do with background tasks, they would use the same mechanism. Thanks to the way launchd works, any tasks killed would be automatically restarted as necessary. Takes care of the memory issue and the user probably doesn't even notice unless that task was what was streaming their audio.

Paul C. said...

Don't forget the battery. Poor battery life has been a nagging issue for the iPhone since the beginning. The added processing from multiple concurrent applications would only make the situation worse.