Swift: The Deceptively Simple Programming Language

When Swift first came out, there were a lot of tweets from non-iOS developers who said something like this:

At first glance, they’re right. Swift has the same ingredients as every other programming language. It has variables, strings, arrays, dictionaries, loops, if statements, switch statements, functions, classes, and more without all that intimidating Objective-C syntax.

objective-c types in swiftSlide from the Swift Interoperability talk at WWDC14.

Feeling excited about the Swift possibilities, I decided to teach it at the Mobile App Workshop I had already planned to teach at General Assembly last weekend. The students included a mix of beginner programmers and people who’ve had much more advanced programming experience, but wanted to get into iOS.

What I learned, unfortunately, is that Swift is definitely not as easy as everyone thinks at first glance. It turns out it’s not that easy to explain var vs let, what optionals are , why they’re necessary, and how to unwrap them, and then of course there are structs, closures, complex enums, downcasting AnyObject, etc. And of course, ARC is still on the table. Try explaining weak vs unowned references in a closure! And I haven’t even gotten to Generics and the super advanced Swift concepts discussed in the Advanced Swift talk at WWDC.

The truth is, I’m still trying to wrap my head around a lot of these concepts myself. Alexis Gallagher gave an incredible talk explaining functional programming concepts used in Swift at the NSMeetup a few nights ago, and he showed this powerful slide:

Swift Objective-CView the full deck here.

The blue Swift concepts are the ones that we have to still know from Objective-C. The yellow ones are slightly new concepts we have to know, and the red Swift concepts are ones that are completely new to us.

These new Swift programming patterns we haven’t ever had in Objective-C will definitely change how we architect our iOS applications. Of course, it is too new to know which patterns will become more main stream than others. Maybe everyone will have their own personal pattern usage, and code bases will vary wildly between projects. Here is an example of an interesting variable capture pattern that Alexis Gallagher had in his slides:

closure variable capture pattern

Here is a more realistic / practical pattern we might see in our apps from Alexis:


It’s definitely an exciting time to be an iOS developer, and Swift makes it exciting because it’s hard. There are a lot of things still in the air (including major changes to the Swift language), and it’s in no way going to be “easy”.

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.