What is Swift? A Brief History & Adoption Trends

by Chinju James

on September 26, 2017

Swift was first introduced by Apple Inc. on 2014 WWDC. It generated considerable debate ever since. Apple‘s Senior Director- Chris Lattner, Developer Tools Department, started designing the basic concept of Swift back in 2010.

Until 2013 the team was not able to solve a strategic question about, how the new language is going to fit the existing Objective C ecosystem. Forcing all iOS developers to move to a new language could have had a major disruptive effect on the community. So apple decided to continue investigating in Obj C while also committing to the development of a new “safe programming language”.

The initial reactions to Swift were mixed at best. Some developers were delighted with its features, flexibility, and simplicity, while others criticized it. Yet, most of them agreed that it was too early for Swift to be used in production. The language was evolving fast: major changes were introduced with every new release.

This, however, didn’t prevent Swift from becoming the “most loved” technology, according to the 2015 StackOverflow Developer Survey.

SWIFT 4

The new Swift language version is largely pronounced as a major language release.It builds on the strengths of Swift 3, delivering greater robustness and stability, providing source code compatibility with Swift 3, making improvements to the standard library, and adding features like smart key paths and serialization, all while shortening build times and reducing the size of app binaries. You’ll be pleased to know it’s nothing as dramatic as the epic changes introduced with Swift 3.0, and indeed most changes are fully backwards-compatible with your existing Swift code. So, while you might need to make a handful of changes it shouldn’t take long.

First in the series of improvements over the last year’s Swift version is new compatibility modes that help you use the new compiler without modifying your existing code. While Swift 3.2 accepts sources from the Swift 3.x compilers and doesn’t include updates to previous APIs, the Swift 4.0 mode has all the latest API changes to give a fresh feel to users.

With Swift 4, you don’t have to modify any of your code to use the new version of the compiler. Instead you can start using the new Swift 4 compiler and migrate at your own pace, taking advantage of new Swift 4 features, one module at a time.

New Features in Swift 4

Swifty encoding and decoding

        Swift 4 introduces a new Codable protocol that lets you serialize and deserialize custom data types without writing any special code – and without having to worry about losing your value types. So, JSON parsing is now available in Swift 4.0.

Improved keypaths for key-value coding

Smart key paths for type-safe, efficient, extensible key value coding for Swift types

Enhancements to creating and manipulating Dictionary and Set types

Faster, easier to use Strings that retain Unicode correctness and add support for creating, using and managing substrings

– One-sided ranges

    Swift 4 introduces Python-like one-sided collection slicing, where the missing side is automatically inferred to be the start or end of the collection.  

Enforced exclusive access to memory

Breaking changes in swift 4

Distinguish between single-tuple and multiple-argument            function types

Limiting @objc inference

Improve interaction between private declarations and extensions

swift 4 vs swift 3

 

  • The migration process from Swift 3.2 to Swift 4 is easier comparing to the previous transition from Swift 2.2 to Swift 3.
  • In Swift 4, variables can be declared private and still be accessed by extensions defined in the same file.
  • Swift 4 adds the ability to define a type declaration as a combination of several types, classes and protocols, together.Swift 3 had no way to express this idea, requiring various ugly workarounds.
  • The target inference rules in Swift 3 Package Manager were a common source of confusion. In swift 4 they revised these rules and removed most of the inference, favoring the practice of explicitly specifying package structure in the manifest

The Swift language has really grown and matured over the years. With these changes in Swift 4, we’re finally getting to a place where ABI stability is right around the corner. The pain of upgrading Swift versions is getting smaller. Build performance and tooling are vastly improving. The use of Swift outside the Apple ecosystem is becoming more and more viable.

Pros of Using Swift for iOS Native Development

  • Rapid development process

A clean and expressive language with a simplified syntax and grammar, Swift is easier to read and write. It is very concise, which means less code is required to perform the same task, as compared to Objective-C. Automatic Reference Counting (ARC) does all the work tracking and managing the app’s memory usage, so developers don’t need to spend time and effort doing that manually. Accordingly, it usually takes less time to build iOS apps with Swift.

A shining example of this advantage is the new Lyft app: The company completely re-wrote its iOS app using Swift. While the old codebase consisted of about 75,000 lines of code, the Swift version recreated the same functionality with less than a third of that. Moreover, the app now featured a new onboarding process: While the old one took more than a month and multiple engineers to implement, the new onboarding with Swift was completed within a week with only one engineer.

2. Easier to scale the product and the team

In addition to faster development time, you get a product that is future-proof and can be extended with new features as needed. Thus, Swift projects are typically easier to scale. The fact that Apple is more likely to support Swift than Objective-C should also get serious consideration for long-term investment.

Moreover, Swift allows you to add more developers to your team if needed: The onboarding is relatively fast due to the simplicity and conciseness of the codebase.

3. Improved safety and performance

As suggested by its name, Swift is made to be… well, swift. With a focus on performance and speed, the language was initially designed to outperform its predecessor. Namely, the initial release claimed a 40 percent increase in performance, as compared to Objective-C. Over the years, multiple benchmarks and tests conducted by individual developers have proved that. Moreover, there are many ways to optimize Swift code for even better performance.

4. Interoperability with Objective-C

As Jordan Morgan, iOS developer at Buffer, wrote in his Medium post, “[…] swift is the new toy and marked as the future. Objective-C is showing its age and will, eventually, be much less prevalent. But in the here and the now, the two must learn to coexist peacefully.” Accordingly, there are two possible scenarios for using both in the same project: You either add new features in Swift to the existing Objective-C codebase, or use Objective-C elements in your new Swift project.

Either way, Swift language is perfectly compatible with Objective-C and can be used interchangeably within the same project. This is especially useful for large projects that are being extended or updated: You can still add more features with Swift, taking advantage of the existing Objective-C codebase. Thus, the porting process becomes easier and more risk-free.

5. Full stack potential and cross-device support

Actively pushed forward by IBM, the initiative to put the language in the cloud has been pretty successful so far. Server-side Swift integrates with most of the popular backend technologies. Just like in full stack Javascript development, using Swift on both backend and frontend of your app allows for extensive code sharing and reuse, speeding up the development process and reducing development efforts.

Moreover, Swift provides out-of-the-box support not only for iPhones and iPads, but for all Apple devices, including Apple TV, Apple Watch, and Mac. Aside from that, there is already support for Linux, and an intention to port it to the Windows platform. There were even some rumors that Google will drop Java in favor of Swift as a first-class language for Android development. However, the recent announcement from Google I/O shows that Kotlin is the future of Android.

6. Vibrant open source community

As Apple’s Senior VP of Software Engineering, Craig Federighi, mentioned “We saw open sourcing as a critical element to make Swift reach its potential to be the language, the major language for the next 20 years of programming in our industry.”

Indeed, with the strong corporate support from Apple and IBM, Swift has quickly gained one of the most active and vibrant open source communities. The adoption trends, mentioned earlier are the case in point. Besides, Swift is currently the most starred language on GitHub, followed by Google’s Go.

  • Share this Article

GET IN TOUCH WITH iLEAF

  • We can initiate development process at the hour of your convenience
  • Discussion on the projects can be held for a stipulated duration
  • We will sign NDA and the talks will be secured
  • We’ll show you around our cherished designs
  • Briefing on technology
  • Guaranteed source code delivery
  • Option to re-start a closed venture

See how we can unwrap your app idea and proceed towards success