Swift – 53 Days Later

The bomb dropped at WWDC. 5,000 of my fellow iOS and Mac Developers were sitting there at Moscone West when Craig Federighi said:

But we had to ask ourselves the question what would it be like if we had Objective-C without the baggage of C?

At that point, there erupted a mixture of nervous laughter, gasps and excitement. My Objective-C heart sank but my curious brain lit up at the opportunity to learn a shiny new language: Swift.

I’ve been fortunate enough to be able to use it almost daily in my work at Capital One. So what have I learned in these past 53 days?

First, Objective-C is not going away yet. We still have a majority of our codebase in Objective-C. All the popular third party libraries that are utilized via CocoaPods are in Objective-C. Fortunately, Apple has built really good interoperability between Swift and Objective-C and vice-versa. My coworker Jonathan Blocksom and I gave a talk about this at MoDev Coders Only, titled “Swift and Objective-C: Best Friends Forever?”

Second, Swift is a real pleasure to code in. It is a lot more succinct due to the lack of header files, square brackets replaced with dot syntax and parentheses, no semi-colons, etc. You do trade in some dynamicness but you gain safety by the compiler doing work for you, like checking that you have assigned variables before use.
There is definitely a transition / learning curve, but it is relatively shallow compared to the one I faced when learning Objective-C back in 2005. Especially since we had to do retain/release and I had come from a series of languages that had garbage collection like Smalltalk and Java.

Third, Xcode betas can be painful. I separate this out from Swift as a language even though they are intertwined. It seems like the Xcode betas are on a two week sprint cycle, so we are on beta 4 as of this writing. This is only a temporary problem though, but I think it has dissuaded a number of developers from jumping in headfirst. Yes, sometimes I do cry when SourceKitService terminates and I lose all syntax highlighting, but that is balanced out by being able to code in a modern language like Swift.

Fourth, Swift has injected a lot of energy into the Apple development community. It hasn’t been buzzing like this since when the iPad first came out. We’re devoting half of iOSDevCampDC to it. I’ve seen a lot of new developers start to come out with the promise of a new, modern language that is more familiar looking. And the allure of a level playing field, since everyone, from Objective-C greybeards to college graduates, have the same challenge and opportunity to learn Swift from scratch.

I’m personally still excited about Swift. I think we’ve barely scratched the surface. We’re entering a new, more modern age of iOS development.