April 17, 2015 // By Jason Bock
I love programming languages. Software development as a whole interests me, but for some reason languages draw me in. I find it interesting to see what different languages provide for their users and how that functionality is expressed with its syntax. Pattern matching, metaprogramming, data binding, multiple inheritance – each programming language I’ve studied and used brings something new to the table for me to digest. And every time that experience has enriched me with a new idea I can use for the projects I’m working on.
So when I had the opportunity to work on a small iPhone project in 2008, I jumped at the chance. iPhones were relatively new, and the Apple world was a new one to me. My career has primarily involved using tools in the Microsoft stack, so I welcomed a chance to broaden my horizons. The project timeline was short – only 4 weeks – so I wasn’t able to do a deep dive, but I got to work with XCode and Objective-C. The end result was, in a word, frustrating. Gratifying, yes, but it definitely has its moments of irritation.
I admit that a fair amount of that frustration was self-generating. It takes time to become proficient at something when it’s completely unknown to you. The Dan Plan is a great example of this in the golfing world. Dan McLaughlin had never played golf in any serious way, and he decided to devote 10,000 hours of practice to become a professional golfer. He started in April 2010, and as of the writing of this article, his handicap is 3.3, which is quite respectable. But it’s taken 4 years of continuous practice to get from a person who could barely swing a club decently to someone who can play very well. The point is that at the beginning of any journey into the unknown, the first steps may be very awkward just because you’re new at it. Therefore, I can’t put all the blame on the tooling and the language.
Throughout its history, Objective-C was never a desirable language for software developers. The only reason it became so popular was due to the incredible rise in popularity of iPhones. If you wanted to create an application for the iPhone ecosystem, you had to use Objective-C. No other choice was available, which is why in mid-2009 its usage took off. Such a restriction seemed odd to me. If you want to create programs that run on the Windows platform, the number of choices is high. You can create scalable real-time systems in Erlang. You can run web servers in Node.js. You can develop web applications using Ruby on Rails or Django. You can craft rich Windows applications using C# and XAML. The point is, you have choices on the Windows platform.
Fortunately, the world is changing for Apple developers. Recently at the WWDC 2014 event, Apple announced a new programming language, Swift. Apple describes Swift as “a new object-oriented programming language for iOS and OS X development. Swift is modern, powerful, and easy to use.” From what I’ve been able to glean from the documentation, I would agree. Here’s just a couple of features that caught my eye:
- Generics – Though it’s not clear if Swift supports covariance and contravariance yet, it’s refreshing to see Swift included generics out of the gate.
- Closures – Having a functional construct like closures opens up a lot of rich development opportunities in APIs.
- Extensions – While it may seem similar to extensions in .NET, it appears to have more capabilities available to developers to extend types.
I’m glad to see Apple release Swift. It’s a refreshing, modern change that seems to bring the Apple programming environment closer to what others have enjoyed for years. The syntax is a nice, reasonable combination of a number of programming dialects and concepts. The Playground looks like IPython, Mathematica or F#. Unfortunately, I can’t play with it. I don’t own a Mac, and the only way to kick the tires on Swift is if you have a Mac. This isn’t true of many languages I know of. If I want to try Ruby, I can easily do that. Same with TypeScript or F#. But nothing like that exists for Swift right now outside of the Apple world. So all my speculation is based on what I’ve read from Apple’s documentation.