When Swift came out, they all shut up

C# programmers have the last laugh

03 Dec 2015

I’ve been sitting on this one for awhile. Since Apple open-sourced Swift today, I thought it’d make sense to publish.

Two and a half years ago, I was building an iOS app at a dinosaur-themed trading company. But it wasn’t built using Xcode — in fact, I didn’t write a single line of Objective-C code for the app.

Instead, we used wrote it in C#.

Every iOS developer I talked to thought we were crazy. “You can’t possibly make a good UI in C#. Everyone knows real iOS apps have to be written in Objective-C!”

They had a reasonable concern — at least, in the context of frameworks like Java Swing and Apache Cordova apps. But they were wrong. “Write once, run anywhere” failed because people tried to reimplement native user interface frameworks. Not because they happened to write code in Java or JavaScript. The ripped-off controls mostly looked and worked like their native counterparts, but hit an uncanny valley that makes apps written with these frameworks feel wrong to users.

Xamarin’s insight was that cross-platform app frameworks didn’t have to recreate the controls. They could just generate bindings into UIKit that would poke and prod the views when the app needed to put something on the screen.

It’s a clever approach that yields performant native apps with shared business logic — business logic written in a language that’s both performant and safe by default. You can even share code with the server: no more writing serialization logic twice, in two different languages. (Dropbox and Microsoft Office adopted this approach too.)

Enter Swift. The day after Craig Federighi and Chris Lattner took the stage to show off Apple’s new programming language, I attended a WWDC-related meetup. This time, nobody batted an eye at iOS apps written in C# — now that bindings were a Cupertino-sanctioned technique, everyone was fine with it.

I think this illustrates a broader problem with our community, and maybe with programmers in general. We tend to maintain made-up beliefs — good apps can only be written in Objective-C, Objective-C is fast because it’s related to C, etc. — that aren’t based in evidence and don’t hold up when subjected to critical thinking.