Email: sales@altexsoft.com

Phone : (877) 777-9097

Request for Proposal
The good and the bad of Swift programming language

The Good and the Bad of Swift Programming Language

With more than 1 billion devices in use as of January, 2016, iOS is the world’s second most popular mobile platform. In some regions, including the USA, the UK, and France, Apple devices continue to outperform Android in smartphone sales numbers. That is why so many businesses focus their software products primarily and sometimes solely on the iOS platform as a key investment opportunity and strategic benefit.

If you are one of those smart business owners following the iOS app development path, probably the most important decision you will make is choosing the right tech stack for your product. If you decide to go for native development instead cross-platform solutions, you still have to decide which language to use: the good old Objective-C or brand-new Swift.

Let’s take a closer look at the critical benefits and drawbacks that accompany Swift. What should you know about this language? Is it ready to be used in production? What are the risks involved in building a Swift app?

To prep for that pros-and-cons discussion, let’s do a quick background check on Apple’s new programming language and outline its current state.

What is Swift? A Brief History and Adoption Trends

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.

Initially, it was really just me messing around and nobody knew about it because it wasn’t anything to know about. But eventually, it got a little bit more serious […] So I started talking to my management and some of the engineers that were working on Clang, and they seemed excited about it. We got a couple people working on it part-time and I convinced my manager that it was interesting enough that we could have a couple of people work on it.

– Chris Lattner for Accidental Tech Podcast, January, 2017

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.

One year later, the registered Apple developers were able to lay their hands on the beta version of the new language. In the first month post its release as a part of Xcode tools, it was downloaded over 11 million times, according to Tim Cook.

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.

Most loved technologies, 2015 StackOverflow Developer Surve

At the same time, the language was listed among top 10 “most wanted” technologies.

Since Apple decided to make Swift an open sourced language in 2015, its growth has been tremendous. Over 60,000 people took a clone of the Swift project in the first week after the announcement. Now, 2 years later, Swift is officially the fastest growing language in history, according to TIOBE Index: The language reached the top 10 in March, 2017.

TIOBE index for Swift

Being free and open to all, the language is growing rapidly with Swift 4.0 scheduled for release later this year. The language is actively deployed in iOS development, when building desktop apps for OSX, or even as a server-side technology, thanks to IBM.

One of the reasons that Swift has become so popular over such a short period is probably the fact that it was made by Apple. When a company with such global name recognition and a multimillion army of loyal followers does something, the chances are it is doomed for success (or at least good press coverage).

Yet, the language itself has a number of advantages that make it the darling of developers. So, let’s look at the benefits of Swift for iOS development.

Pros of Using Swift for iOS Native Development

Often referred to as “Objective-C, without the C,” Swift language is in many aspects superior to its predecessor. According to the official press release, “Swift combines the performance and efficiency of compiled languages with the simplicity and interactivity of popular scripting languages.” Leaving technology details and marketing aside, let’s see what it really means from a business perspective.

  • 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.

  • 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.

  • 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.

Apple WWDC 2014 presentation

Image source – AppleInsider Live Blog

Another of Swift’s strengths is its safety. Its strong typing system and error handling prevents code crashes and errors in production. Thus, Swift has a shorter feedback loop, allowing you to see the errors in the code instantly and fix them on the fly, greatly reducing the time and effort needed for bug fixing and eliminating the risks of deploying low quality code.

  • 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.

  • 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.

  • Vibrant open source community

As Apple’s Senior VP of Software Engineering, Craig Federighi, mentionedWe 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.

swift vs go on github

Source – github.com

The Cons of Swift Programming Language

While there seem to be so many reasons to love Swift, the language is still far from perfect. Many developers and business owners are overly cautious when it comes to switching to the new language. There are several reasons for that.

  • The language is still quite young

Swift might be the fastest and most powerful language in the world, but still too young. It has many issues that need to be addressed and “growing pains” to experience. After all, three years is too little time for any language to mature, even if it is Swift.

Moreover, Swift still has a very limited number of “native” libraries and tools: Many of the available resources and tools dedicated to earlier Swift versions are useless with the newer releases.

  • Swift is considered a “moving target”

That said, it follows that Swift is often considered to be unstable due to the major changes that are introduced with every new release. One of the key problems articulated by many developers is the lack of backward compatibility with the older language versions. Consequently, developers are forced to completely rewrite their projects if they want to switch to the latest Swift version.

While Xcode provides a tool to help developers update their Swift code to newer versions, it doesn’t fix all the issues. Thus, porting your project to a newer Swift version can be time consuming and costly. If you have a very large project or a project that you don’t plan to update too often, Swift might be not the best option for you, at least for now.

  • Limited talent pool

While the Swift community is growing fast, it is still significantly smaller as compared to any other open source language. According to the latest StackOverflow Developer Survey, only 6.5 percent of the 64,000 respondents use Swift. At the same time, Upwork.com, a global freelance marketplace, finds that the demand for Swift programmers is growing, which might result in a talent gap.

While there are not many Swift developers out there, even fewer of them have decent hands-on experience with the language. There is probably only one person who has such experience with Swift, but Tesla already snagged that player for their roster.

  • Poor interoperability with third-party tools and IDEs

Largely due to frequent updates and lacking backward compatibility, as mentioned above, it is often hard to find the right tools to help with the certain tasks. Moreover, the official Apple IDE, XCode, lags in terms of tooling and support for Swift. Developers often report issues with syntax highlighting, autocomplete, refactoring tools, and compilers.

  • Lack of support for earlier iOS versions

You can only use Swift in the apps that target iOS7 and later. That said, Swift can’t be used for legacy projects running on older versions of the operating system.

However, per recent research, less than 5% of Apple devices currently run on iOS8 or earlier.

ios versions adoption trends

Source – david-smith.org

Can Swift Be the Future of iOS Development?

Despite its tender age and the attendant controversy, Swift already has a number of prominent success stories. Some of the companies that chose the new language are Lyft, LinkedIn, Coursera, Pandora, Vimeo, Twitter, Fitbit, and Groupon. Moreover, Facebook and Uber are reported to have shown significant interest in Swift.

With the new, purportedly more stable version of Swift scheduled for release later this year, many of the listed drawbacks will hopefully be addressed. Thus, 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 crucial to be ready for any changes the market might impose. Thus, preparing 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.

 

This post is a part of our “The Good and the Bad” series. For more information about the pros and cons of the most popular technologies, see the other articles from the series:

The Good and The Bad of Xamarin Mobile Development

The Good and the Bad of JavaScript Full Stack Development

The Good and the Bad of Node.js Web App Development

The Good and the Bad of ReactJS and React Native

Add Comments

Comments

Leave a Reply


wpDiscuz