When Apple announced Swift at WWDC 2014, it came as a sweet surprise for the developer community involved in iOS development. The event is generally a showcase for updated hardware and new product launched by Apple, rather than a platform for releasing whole new programming languages. Although the developers welcomed the release of a modern and more refined programming platform for developing iOS applications, there were some apprehensions on their part, initially. Primary among them was the level of usability offered by the new Swift platform and the benefits of starting to work on it from scratch as opposed to the proven old brute – Objective-C.
Yet, the release of Swift was in a way an uncharacteristic delay on Apple’s part too. The company, which is notorious for promoting beauty and symmetry even for product parts a customer cannot see, had been curiously lethargic in releasing a new programming platform. Objective-C is known for its relative difficulty due to the inclusion of numerous unstructured functionalities and legacy APIs. The language had been around for almost two decades before Apple decided to use it. Apple has been using Objective-C since iOS development started in earnest under Steve Jobs.
In 2015, one year after showcasing the advantages of Swift, Apple made it open source. This was perhaps the single largest reason that drove Swift’s popularity among major developers, startups and individual shops. Come WWDC 2017, only three years after its launch, Swift has effectively replaced Objective-C as the primary language for developing all Apple OS related apps. Swift is now the 10th most popular programming language in use, whereas Objective-C (at number 3 a couple of years ago), now sits at the 16th place. Today, global giants like Facebook, Uber, Mozilla and IBM are using the Swift code for their iOS Apps. And with iOS 11 it is all set to reach newer heights providing better customer experience.
How is Swift different from Objective-C?
Swift is a much more refined programming version of Objective-C. The new platform supports advanced functions such as automatic memory management, dynamic libraries while having definitively simplified coding. Swift is also easier to master in comparison to other programming languages, especially the once widely used Objective-C. If you are a seasoned hand in iOS app development, you can master Swift well within a month or so. Apple has also promoted Swift as the programming language of the future as opposed to the now thirty-three-year-old Objective-C. The company plans to use Swift for app development for all its platforms in coming decades.
Swift offers a greater functional value than Objective-C to developers. It enables Automatic Resource Counting (ARC) across all procedural and object-oriented code paths by default. And taking this into consideration, Apple has profoundly included iOS 11 for better results. In comparison, Objective-C only allows ARC support inside Cocoa APIs and certain object-oriented codes. Notably, Objective-C completely lacks support for procedural C code for APIs. This means, while working with APIs like core graphics, programmers have to actively monitor memory management to avoid overloading the compilers. Contrastingly, Swift by nature is designed to plug memory leakages without any need for manual intervention.
Swift has an inbuilt support for dynamic libraries, a feature coveted by most modern-day mobile app programmers. Use of dynamic libraries significantly boosts the process of releasing application updates and bug fixes and thus will help in gelling with the latest iOS 11. Swift app developers can simply connect older Swift code to newer compilations by using an electronic signature and including an NSA certificate. Using dynamic libraries has also reduced average application sizes in the App Store. And the best part is that the dynamic libraries are also open source and come included in the App Store Market Download Package.
Apart from its functional advantages, Swift is a remarkably easy language to code with. Where Object-C frequently needs sorting out functions and syntax to avoid conflict, Swift uses higher order functions to reduce coding conflicts. Most complex coding functions can be expressed in single line code with Swift, which is a definite advantage in modern-day software development environments.
The real benefits offered by Swift
Swift apps performance on iOS is noticeably faster than their Objective-C and Python counter parts. Having a simplified and fast coding structure means a reduced app development cycle for developers as apps require considerably less lines of code to write in Swift, thus becoming extremely feasible with iOS 11. A prime example of the leaner Swift code is demonstrated by the rewritten Lyft app. The new app has less than a third of the original 75,000+ lines of code (which was written in Objective-C) while retaining the same levels of functionality. Swift is also competing toe-to-toe with C++, which is considered as the fastest algorithm arithmetic. Swift even managed to outpace C++ in several computation algorithms, whereas Objective-C continues to be bottlenecked by its legacy C API.
Better Returns on Investment:
According to research data released by Stack Overflow, Swift app developers charge less for iOS app development than Objective-C developers in the industry. The ROI on Swift is also better due to the fact that it’s now an open-source programming platform, thus making it a lucrative prospect for startup app developers. Being one of the only two iOS app development options, implementing Swift certainly helps save precious capital. Companies around the globe are saving an estimated $61 billion per year by using Swift code for programming.
Apps that do not crash:
Apple eliminated a lot of legacy stuff from Swift’s structure in a bid to give it a much cleaner look and feel. The syntax, idioms and closures used in Swift are enormously simplified and yet retain the ability to write complex functions. For app developers, this means apps which are less prone to inherent errors and crashes, if at all. An example of Swift’s fail-safe mechanisms is the use of a null optional variable, which triggers a run-time crash, forcing the app developers to fix the issue then and there before proceeding further with a program.
Sirikit Extension Support, Voila!
Developers can integrate Siri in their apps with the Apple’s SiriKit Extension support for Swift. The SiriKit includes two extensions –Intent Extension and Intent UI Extension. The intent extensions are used by Siri to initiate communication with the app service, whereas the UI extension allows insertion of a custom view to show an action to the user. Apple has resisted the demand from developers for more native support to utilize the full potential of Siri commands in third-party apps. Still, the Intent Extensions do provide a lot of headroom for third-party developers by integrating the most useful features of the Cupertino’s smart assistant.
Support for Augment Reality Apps
One of the biggest announcements at WWDC 2017, was the release of Apple’s ARKit (basically a fancy way of saying Augment Reality Kit). Apple execs also demoed a basic usage scenario of the ARKit to create an augmented reality experience using the iPhone and iPad cameras. Developers are already drooling over the possibilities offered by a combination of Swift and ARKit functionalities, which is nothing to be surprised at after last year’s smash hit – the Pokémon Go app. Apple has arrived a bit late to the augmented reality game, given that Google’s been Tangoing for some time now. But since this is Apple we are talking about, the ARKit might still steal the show in augment reality app development.
We have repeatedly stressed on the concise code of Swift in this post, which is essentially the foundation stone for all its pros. Adding another one to the list –the Swift code also allows developers to write more secure and easy to maintain apps. Swift’s use of dynamic libraries (also mentioned earlier) not only helps developers in releasing security patches and bug fixes quickly but also benefits data conscious end users by keeping download sizes low.
Swift in its 4th iteration is a more refined and appealing prospect for iOS developers than it was three years ago. Apple has partnered with IBM for developing Swift as one of the primary coding languages of the 21st century. First, the Siri Extension Support and now the ARKit release has vastly improved the usage scenarios offered by Swift for iOS developers. Furthermore, Apple plans to use Swift for not just iOS but also macOS, tvOS and watchOS applications. With the release of the much-awaited iPhone 8 (if only they are calling it that) and more powerful refreshes to the Mac lineup, just around the corner, it is probably the best time to invest in learning Swift app development. Swift now also has a flourishing community on GitHub and Apple is continuously releasing updates to the Swift code in contrast to Objective-C, where development has slowed down in the last couple of years.
Moreover, in April 2016, Google surprisingly announced that it will soon start supporting Swift for Android app development. Although, the news should be taken with a pinch of salt given with the huge revamp required to Google’s APIs and SDKs for a complete switch to Swift. The announcement, however, definitely leaves room for some positive speculation. If the world’s two most popular mobile ecosystems somehow start using a common programming language, the imperatives of learning it becomes a no-brainer for any dev.
Latest posts by Ashish Parmar (see all)
- Adopting Swift for Better App Development in iOS 11 - September 26, 2017
- Business Analytics and Big Data Unlocking the True Potentials of Mobile Apps - April 14, 2017