The beta launch of Swift at the Apple Worldwide Developer’s Conference in June 2014 opened the door for a new generation of Apple programming. Apple intends for Swift to be the eventual successor to its stalwart programming language, Objective-C, the basis for all of Apple’s applications since 1996. At less than a year old, Swift has already made some headway with developers and in the open source community. But although Swift may be the right choice in some situations, it may be too early for enterprises to adopt it fully.
What Makes It Swift?
Apple calls Swift “Objective-C without the C.” The language was created for several reasons, but chiefly to re-energize the developer community and attract new, young developers from a variety of development backgrounds and encourage them to get into mobile by lowering the barrier to entry. Swift is accessible to developers who already know scripting languages with similar syntax, such as JavaScript, Haskell, C#, Python, Rust, Java, and of course, Objective-C.
As its name implies, Swift is intended to be a faster language than Objective-C, well suited for apps with heavy animation, like gaming apps. However, in reality, it might not be much faster. This is because both languages target the same Cocoa and Cocoa Touch APIs (for OS X and iOS, respectively), both are statically typed languages, and both use the same LLVM compiler. Apple has stated that Swift is up to 2.6 times faster than Objective-C when completing a common search algorithm, but comparative tests will need to be performed when more mature Swift apps are developed.
Fast Rate of Adoption
Because of its relative simplicity and lower barrier of entry, Swift’s goal is to reduce the complexity of creating apps for Apple’s operating systems, iOS and OS X. A popular image on Twitter following Swift’s announcement, shown to the right, illustrates the excitement and a bit of uncertainty in the developer community for a language that’s simpler to learn and master. If you’re teaching yourself Objective-C, should you stop now and jump into Swift? Which should you learn first?
Apple has generated significant excitement for Swift in the developer community and started accepting Swift-coded iOS apps into the App Store starting September 10, 2014. At the beginning of the third quarter of 2014, RedMonk ranked Swift as the 68th most popular programming language; by January 2015, Swift surged to number 22.
Not Quite Ready for Prime Time
In rapid succession, Apple has released four versions of Swift: The original beta (June 2014), Swift 1.0 (September 2014, coordinated with the release of iOS8), Swift 1.2 beta (February 2015), and Swift 1.2 (April 2015).
Following the release of Swift 1.2, Apple noted on its developer blog, “We appreciate all of the bugs you have filed, and expect that many of the most common issues have been fixed in this beta. Swift 1.2 is a major step forward for both the language and the tools.”
As a consultant responsible for delivering iOS apps for enterprises, I don’t advise relying on such a young language whose bugs are still being worked out. Of course, the bigger question is resource constraints. Even with the rapid rise in Swift’s popularity, there’s a shortage of Swift developers currently compared to Objective-C developers.
Multiple Choices When You Want to Build an iOS App
In the past, there hasn’t been much of a choice when building mobile apps for Apple. Apps had to be written in Objective-C. Now you have three choices: Swift only, Objective-C only, or a combination of the two.
- Small Team, Start-Up, or Personal App? Consider Swift.
Swift might make good sense when you have a small, committed team and are unlikely to experience resource issues, or better yet, when an individual manages updates to an app. Swift offers many modern and expressive features to reduce code, making it cleaner and less error prone. The open source community has created easy to integrate frameworks, like AFNetworking, which now supports Swift. As adoption increases, core bugs will be flushed out and it will be safer and easier to use for larger teams and projects.
- Enterprise? Use Objective-C Only.
When your team is larger, and especially when members are rotating in and out, you need more stability. Objective-C is a mature language and widely in use for app development at enterprises; it was noted by RedMonk as the 10th most popular programming language in January 2015. Because there is a greater availability of developers who can support Objective-C-based apps, it is the better choice for most businesses, especially large enterprises.
- Adventurous? Use a Combination of Objective-C and Swift.
Apple has enabled Swift code to be compatible with Objective-C code, allowing for both to be used side-by-side in the same code base. Apple endorses this on its website and there are benefits to embracing new and changing technology early, but you should think about the drawbacks as well. Mixing two languages in your code base creates confusion for developers, especially in large teams, and creates the same resource problems as a Swift-only approach.
At this time, the majority of enterprises are best served by waiting on Swift until the language matures and adoption increases. Apple’s strongly pushing Swift to be the language of choice for iOS and OS X sometime in the future, but for most projects, it’s best to hold off on Swift, the new and exciting, and continue to develop in Objective-C, the tried and true. However, adoption is key so it’s not about the “right”; it’s more about “right now”. We’ll see what happens with iOS 9 and WWDC over the next few months.
Brian Westendorf
Brian Westendorf has more than 15 years of experience in software engineering with an emphasis on people and teams, mobile applications, enterprise e-commerce, POS, agile development, and content distribution systems. Brian’s expertise extends to all aspects of the software lifecycle, including business and project planning, design and front-end development, web services, and complex database design.