Swift?

I won’t blame you if you’ve never heard about Swift before. It’s a programming language just like C++, Java or Python. So why did Apple reinvent the wheel when there are so many alternatives to it?

Simplicity. Just like everything made by Apple, Swift is simple, elegant and very easy to understand and work with.

What is it?

Swift is a compiled programming language for iOS, iPadOS, macOS, watchOS, tvOS, and Linux applications.

It’s safe because its syntax encourages you to write clean and consistent code. It also provides safeguards to prevent errors and improve readability.

And more importantly, it’s fast. Very fast. Swift was built with performance in mind. Not only does its simple syntax and hand-holding help you develop faster, it also lives up to its name. And keep in mind, it is 2.6x faster than Objective-C and 8x faster than Python.

A brief history about Swift

First introduced at Apple’s 2014 Worldwide Developers Conference (WWDC), Swift programming language has generated considerable debate ever since. Chris Lattner, Apple’s Senior Director, Developer Tools Department, started designing the basic concepts of the new language back in 2010.

It wasn’t until 2013 that the team was able to solve a strategic question about how the new language would fit in with 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, the company decided to continue investing in Objective-C while also committing to the development of a new “safe programming language.”

But in 2015, there was a major turning point for Swift – it became open-source. Ever since then, it’s growth has been huge, being adopted and loved by millions around the world.

Swift 5.0

In March 2019, Swift 5.0 was officially released by Apple. The current version of Swift now contains a stable version of the application binary interface (ABI) across Apple’s platforms. This is a giant step toward helping developers use Swift on dedicated OSs like iOS, iPadOS, macOS, tvOS, and watchOS. Needless to say, Apple is building a solid ecosystem, as now standard Swift libraries are included in OS releases.

SwiftUI was introduced in the release, which is basically a library of controls, graphic elements, and layouts for Swift applications that can be used to design user interface. The update also brought renewed documentation, updated CLI Xcode 10.2, and binaries for Ubuntu. Swift also became backward compatible with its previous versions. The list of languages that it is interoperable with now includes Ruby, Python, and JavaScript.

Since the release version 5.0, standard Swift libraries are integrated into every macOS, iOS, tvOS, and watchOS release. That means any app built on those platforms will be smaller, because these libraries are included. With this advancement, stable application binary interface (ABI) was also released. This allows Apple to provide support of Swift across its platforms.

Why you would want to use Swift over other alternatives

Well, first of all – the development process is extremely fast. Swift is very easy to write and read, being 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.

In addition to faster development time, we can say that Swift 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.

Additionally, Swift allows you to add more developers to your team if needed: The on-boarding is relatively fast due to the simplicity and conciseness of the code-base. The syntax of Swift is considered near to natural English, thus it offers easy readability for new team members.

Static vs. dynamic libraries

 

Usually, when you build an app, you use a lot of third-party code – reusable and often open source frameworks or libraries compiled into your app’s code. These libraries can be static and dynamic (or shared). Swift first introduced dynamic libraries to iOS when it launched. Usually, static libraries become the part of your executable file, thus increasing its size and load time. They also can’t be automatically updated since they’re stuck in the version you compiled at. Dynamic libraries, on the other hand, exist outside of your code and are uploaded only when needed. Static libraries need to have copies in all files of your program while dynamic ones do not.

Even though it takes more time to reach for the dynamic code from the outside than call to it when it’s already included, you have a choice to keep using static libraries when you want to isolate apps that aren’t meant to be shared.

ARC – Automatic Memory Counting

Swift uses Automatic Memory Counting (ARC) – a technology aimed to add a garbage collector function that wasn’t introduced to iOS before. Languages like Java, C#, and Go use garbage collectors to delete class instances that are no longer used. They are useful to decrease your memory footprint but can add a lot of extra unnecessary CPU usage.

Before ARC, iOS developers had to manage memory manually and constantly manage retain counts of every class. Swift’s ARC determines which instances are no longer in use and gets rid of them on your behalf. It allows you to increase your app’s performance without lagging your memory or CPU.

To sum up

For such a young programming language, Swift surely has an great variety of resources to help developers accelerate adoption. Apart from official e-books, there are tons of community guidelines, podcasts, online and even real-life courses and even third-party apps.

Swift has become an even more mature language with the latest update, but there are still a few things that need fixing. Apple is creating its own ecosystem with a stable ABI over its platforms, but it still lacks tooling and support for earlier versions. As such, Swift adoption will continue to grow, which soon might lead to a complete displacement of Objective-C as the leading first-class language for iOS mobile application development.

For business owners, it is important to be ready for any changes the market might impose. Thus, being prepared to switch to the new language with minimum effort and at a reasonable cost should be one of the key strategies for the near future.