Apple’s other iOS app vector, the Open Web, is finally catching up.
There’s a reason that Cocoa, Apple’s flagship set of application development frameworks, is written, essentially, in C.
Cocoa, like any world-class framework, is a beast of abstraction: it exists to make the complex simple. Take Key Value Observing (KVO). This mainstay of MVC and related patterns allows you to bind two properties on two different, disparate objects, together. If one of them changes, the other one updates. This lets you do trivial things like change the background color when the user updates the setting, or crucial things like display data as it loads from a server.
It’s pretty hard to overstate the impact that KVO can have on your code. When values automatically stay synced, different parts of your application don’t need to know about each other. Separation of concerns, code sharing between applications, all kinds of Best Practices become Easy Practices. And, once you’ve set up your binding, triggering that cascade of updates is as simple as this:
[obj setValue:newValue forKey:@"propertyName"];
It’s like magic!
Of course it’s not actually magic, it’s abstraction at work, and it comes with a cost. That one easy line of code wraps dozens or hundreds of internal commands and complex data structures. All of the bound properties that need syncing, all of the observing methods that need calling, they all need to be tracked, updated, and properly disposed of when the time comes. So suddenly one simple command – a basic KVO setter – is triggering an invisible avalanche. Good abstractions come with the danger of allowing developers to run tons of code without the bother of having to write tons of code.
When you’ve got layers of abstraction serving as code multipliers like that, the underlying code needs to be fast. And it needs to be even faster to run on the iPhone, with its memory restrictions and puny CPU. So, with its eyes firmly on speed, Apple has bullheadedly refused to follow industry trends towards heavily interpreted languages. Even its experiment with garbage collection was canceled just a generation after it began. Cocoa remains Objective-C: a speedy superset of C, and as uninterpreted a language as you’ll find. And it needs to be, in order to stay fast when there’s so much abstraction in the air.
obj.set('propertyName', newValue); – triggers its own invisible, sophisticated, expensive avalanche.
That abstraction is extraordinarily powerful: SproutCore uses it to bring sophisticated application development strategies and sensibilities to the web application arena, a space which is often sorely lacking in them. A SproutCore application will have well-organized, well-segregated models, views and controllers, managed by a powerful state machine and tied together with the magic of KVO. In short, a SproutCore application will be an application. It just happens to run in the browser.
It’s 2014, and the iPhone can deliver. Time to start creating.