FREN

#FF00AA


26 oct. 2014

The Third Coming of Objective-C?

I’ve already written about how much I dislike Swift, and how much more I resent it for signaling the death of Objective-C: just like everyone could read the writing on the wall regarding Carbon and knew they had to port their apps to Cocoa as soon as possible, the Swift announcement seemed to make it obvious that Objective-C is now an evolutionary dead end that I will have to abandon sooner than later, despite my strong preference for nil messaging.

But John Siracusa’s digression on Swift in his Yosemite review suddenly gave me what could either be new hope or utter delusion:

The Swift compiler introduces another step and another intermediate form into the compilation process: Swift Intermediate Language (SIL). Here’s the process for compiling Swift code for an x86-64 CPU using swiftc. […]

It’s worth considering why SIL exists at all. […] Despite the obvious benefits of SIL in its current role, a syntax-independent, high-level intermediate form with its own optimizer definitely seems like a technology with some potential. It’s possible that the larger purpose of SIL has not yet been revealed.

How far-fetched is it to imagine that, a few years down the line, Objective-C code could be compiled into SIL? I’m sure Apple will want to get rid of the Obj-C runtime in a few years (or at least stop loading it in memory by default — which would make Obj-C apps second-class citizens that start up and run slower on future devices), but what if that legacy code was able to run on top of the Swift runtime?

Of course, there are integral, structural differences between Objective-C and Swift, which would make such a translation extremely complicated and costly in resources, but… wait, are there?

Despite its rich feature set, the Swift language itself is actually quite minimal. All the basic data types are not part of the language proper. They’re part of the Swift standard library that is loaded automatically by the compiler—and the Swift standard library is written in Swift [and named Swift].

Could Objective-C code be translated into SIL and linked to an “ObjectiveC” library? Could existing Objective-C binaries be translated into SIL, even, so that legacy apps from the Store would still be able to run on top of Swift?

I don’t know nearly enough about languages and compilers to have an idea of how complicated what I’m suggesting might be. But I understand that the engineers in charge of Apple’s compilers and development tools are a pretty smart bunch, so who better to do something like this?

Vous voulez savoir quand je poste du contenu sur mon blog ? Il suffit de vous inscrire gratuitement à un agrégateur RSS (Feedly, NewsBlur, Inoreader, …) et d'ajouter www.ff00aa.com à vos flux (ou www.garoo.net pour vous abonner à tous les sujets). On n'a pas besoin de newsletters, pas besoin de Twitter, le RSS existe toujours.

Mentions légales : ce blog est hébergé par OVH, 2 rue Kellermann, 59100 Roubaix, France, www.ovhcloud.com.

Les données des visiteurs de ce blog ne sont pas utilisées ni transmises à des tiers. Les posteurs de commentaires peuvent demander leur suppression par e-mail.

Tous contenus © de l'auteur ou couverts par le droit de citation.