Tuesday, July 22, 2014

Carbon and Cocoa as a Metaphor for Objective-C and Swift

Michael Buckley:

But even the Cocoa version of InDesign is not a great platform citizen. OS X reports that it always uses significant energy, even when idle. Its dialog boxes are just an NSWindow with an NSView. Adobe draws text and buttons in the NSView, and tracks mouse clicks in the view manually. Since there are no NSTextFields or NSButtons, these dialogs are completely invisible to screen readers.

This is in stark contrast to Lightroom, which was written with Cocoa in mind from the beginning. It's still a cross-platform app, but all of its UI elements are subclasses of Cocoa classes. The app is accessible, and it doesn't use significant energy while idle. More importantly, it can quickly adopt new features of the OS.

[…]

There are many features of Swift that make it a great language for Apple to write its future frameworks in. It probably won't be long until some of these frameworks start to use Swift-only features like generics. Taking full advantage of platform improvements requires adopting new frameworks, and any Objective-C programs that wants to use these frameworks will need to write adapter code in Swift.

But Swift and Objective-C have different design philosophies. As time goes on, it will be harder to reconcile Objective-C's design philosophy with native Swift frameworks. In order to simply get their apps to work, developers will spend a lot of time figuring out how to refactor their existing Objective-C codebases to fit within the constraints imposed by Swift, leaving them with less time for other improvements.

Update (2014-07-23): Chris Lattner:

Swift is a new option for developing on the platform. We have no plans to drop C, C++ or Objective-C. If you’re happy with them, please feel free to keep using them.

Of course, that’s what Apple said about Carbon as well.

2 Comments

What crap. How much API churn can Apple cram down the throats of third-party devs?

It would have been trivial for Apple to support 64-bit Carbon--the work was already done when they pulled the plug. Leaving the API's frozen except for minimal maintenance with a small staff of developers could have been easily done.

I wonder if Objective C is now going to be subject to bit-rot as well.

@Kevin Let's first see whether Swift is going to be a success or not. Now that the reality distortion field of WWDC has dwindled, more and more developers are having doubts about the advantages of moving to Swift considering the restrictions and the illegibility of this language.

Personally, I consider Swift at this time to be a language designed by C++ addicts who believe that because they've provided an interpreter (Playground),Swift is easy to learn and appreciate. The blood marks on the walls and the bandages around my head tell me another story.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment