Friday, September 18, 2015

Objective-C Is Our Generation’s COBOL

Drew Crawford (tweet):

Sometime this year, probably right around now, Swift will surpass ObjC in search traffic. The number of people trying to google some Swift question will be greater than the number of people googling some ObjC question. Around now. Not next year, not when you’re planning your next major version and might have more time to think about porting a few classes. Right now.

[…]

Pretty much every new iOS developer I talk to is learning Swift. Not ObjC. Not Swift and ObjC. Just the Swift.

[…]

Your ObjC codebase isn’t going to go away. Just the people willing to work on it. Sorry.

My first reaction is to point out that of course there’s more search traffic for a language that’s new, in flux, and much more complex than its predecessor. That said, it’s quite possible that we have reached Peak Objective-C.

I’m having a good experience with Swift so far. It fixes so many things that have long annoyed me. There are certainly problems with Swift, but Apple is working at an impressive pace to address them. I do worry a bit that using Swift is going to paint me into a corner. Crawford writes:

Swift is essentially a superset of ObjC. Other than a few weird trivia questions (#pragma pack anyone?) you can do everything in Swift that you can in ObjC, and much, much, more.

This is mostly true, and you can migrate code piecemeal, but it does seem like there’s a point of no return. First, you cannot subclass a Swift class in Objective-C. Second, it doesn’t interoperate with C++. Third, Apple doesn’t really talk about it, but the bridge for Objective-C and Swift strings and collections is not toll-free. There seems to be overhead in just passing bridged objects back and forth between the two languages. This is probably not a problem in most cases, but it’s not clear to me what you can do if this bites you.

This is more a problem with Swift interoperating with Cocoa than with Swift the language. But if you’re writing an app, working well with Cocoa is what matters.

Ben Sandofsky:

I’m bullish about Swift, but it’s nuts to port a large, mission critical app to it, today.

Andy Matuschak:

This is a pretty accurate analysis. Having been an early patient, I can report mixed outcomes and excitement about the future.

Tim Burks:

I’m aware of two projects, one at a startup and one at a big big company, that were rewritten in ObjC after starting in Swift.

Ben Sandofsky:

Every new line of Objective-C you write today is technical debt in a Swift world.

Update (2016-03-22): Joris Kluivers:

Had to revert back to Objective-C for a delegate implementation. NSDictionary -> Swift Dictionary conversion for a param didn’t perform well

7 Comments RSS · Twitter

Look at the El Capitan binaries. Apple is pushing Swift, but they aren't using Swift. They've shipped to a close approximation zero lines of Swift code in OS X. Externally, a lot of developers are jumping on the bandwagon, but internally it's a different story. When they start trying to rewrite things in Swift, they're going to find themselves with a lot more "discoveryd"s. They don't have the personnel to rewrite everything in Swift and also keep up their once a year OS release schedule. At this point, there's very little reason to think that Swift is the future. We've heard that before, with garbage collection, and remember what happened there. I think it's foolish to write Swift apps before Apple writes Swift apps.

A significant number of developers who have made peace with Objective-C will be less likely to do so with Swift when they, like me, learn that Swift needs an Objective-C shim to interact with any C library. The question then becomes, what is the point of Swift? Whatever advantages it has over plain Objective-C, a developer who depends on a C-based stack has no use for it.

@Kevin “Swift needs an Objective-C shim to interact with any C library.” Are you sure that’s right?

@Michael: That seems to be the case, based on what I read here:

http://spin.atomicobject.com/2015/02/23/c-libraries-swift/

I've been on numerous projects using Swift that have suffered major setbacks due to compatibilities with other libraries. As a result, I will not be switching to Swift full time any time soon. It's just not ready in enterprise and large startup environments. For individual developers and smaller startups it's definitely enticin, but your mileage may vary.

This article's title is meant to be provocative. Suggesting that Objective-C is this generation's COBOL is purely speculative..

What percentage of apps don't need to interoperate with cocoa? It seems to me that swift's biggest weekness is that it does not interoperate well with the APIs that all swift developers must use to get anything done.

[…] many benefits from pure Swift not doing message sending, and they may incur extra overhead due to bridging. Writing the code may be faster, […]

Leave a Comment