SWIFT

Your phone is capable of almost anything these days, from looking up recipes you will make tonight to downloading various interesting apps. According to Statcounter’s survey, iOS has been installed on 24.79 percent of all mobile devices, which is the second popular mobile platform.

Apple or iOS developers are using Objective-C language to write code for more than two decades, but Apple introduced a new language, Swift to minimize written code. Swift allows developers from different backgrounds to get started with developing on iOS and OSX much easier. Swift is incredibly powerful and you can reduce your code at least a fourth if you start integrating it into your code-base.

So let’s get familiar with Swift more!

About SWIFT (Platforms)

Swift is a fantastic way to write software, whether it’s for phones, desktops, servers, or anything else that runs code. Swift is a safe, fast, and interactive programming language that combines the best in modern language thinking with wisdom from the wider Apple engineering culture and the diverse contributions from its open-source community.

Its code is safe by design, yet also produces software that runs lightning-fast. It is used to build apps for iOS, watchOS, macOS, tvOS, and Linux.

History of SWIFT

Swift was made by Apple Inc. especially for iOS devices on June 2, 2014. The development of Swift was started in 2010 by Chris Lattner with other programmers. The language ideas for Swift were taken from Rust, Objective-C, Ruby, Haskell, C#, CLU, Python, and a range of other programming languages.

Apple created Swift to work with both Cocoa and Cocoa Touch and Swift is an extensive set of Objective-C codes that have been written for the products of Apple Incorporation. It is built with the open-source LLVM compiler framework and has been included in 2014.

Although Swift was inspired by Objective-C and many other languages, Swift is not itself a C-derived language. As a complete and independent language, Swift packages core functions like flow control, data structures, and functions with high-level constructs like objects, and protocols.

Version history

Swift’s first version which is Swift 1.0 was released on the 9th of September 2014. The company also introduced the Gold Master of Xcode 6.0 for iOS side by side with this release.

Swift 1.1 was introduced, along with the Xcode 6.1, in the 22nd of October 22, 2014. The range of developments continued until the introduction of Swift 2.0 at WWDC 2015.

Its upgraded version 2.2 was made open-source software under the Apache License 2.0 on December 3, 2015, for Apple’s platforms and Linux.

The company also introduced a rough framework for the development of Swift 3.0 on a blog in December 2015. The introduction of an intermittent version was made before the 3.0. Swift 2.2 — the intermittent version — introduced new features and syntax in the language. Some outdated components were also eliminated from the language with this version.

According to the Stack Overflow Developer Survey 2015, Swift gained first stand as the Most Loved Programming Language. The language maintained second place in the 2016 survey. Because of the ever-increasing functionality and popularity of Swift, it is said that Google is considering to use Swift as the primary programming language for Android, which is the operating system of Google.

Swift language popularity (Trends)

Firstly, please look at this graph. This survey shows Swift is the most loved technology in 2015. 26,086 people in 157 countries, they loved, dreaded, and wanted Swift.

Source: 2015 StackOverflow Developer Survey

Swift topped the “Most Loved” languages and technologies (cited by 77.6 percent of respondents), followed by C++11 (75.6 percent), Rust (73.8 percent), Go (72.5 percent), and Clojure (71 percent).

At the same time, the language was listed among the top 10 “most wanted” technologies. Swift is a relatively new language, but why it is so popular? A recent list from RedMonk, a tech-industry analyst firm, ranked Swift 22nd in popularity among programming languages, based on data drawn from GitHub and Stack Overflow. Perhaps developers are increasingly overjoyed at the prospect Apple has positioned Swift to replace.

Now Uber, Airbnb, Square, the meditation app Calm, and some 500,000 other apps on the App Store are at least partially written in Swift.

What is Objective-C language which inspired Swift?

Objective-C is the primary programming language you use when writing code software for Apple OS X and iOS. It was first introduced in 1984. While it is not specific to any particular platform or system, it can greatly aid in developing a variety of other frameworks.

Simplest function in Objective-C language and Swift, shown below.

Example of objective-C languages

import

int main ( void ) {

NSAutoreleasePool * pool = [ [ NSAutoreleasePool alloc ] init ] ;

/ / Your code here!

NSString * s = @ “ Hello Objective-C ” ;

[ [ NSFileHandle fileHandleWithStandardOutput ] writeData : [ s dataUsingEncoding : NSUTF8StringEncoding ] ] ;

[ pool release ] ;

return 0 ;

}

Example of Swift

print (“Hello Swift”)

Above each code represent just simple ‘Hello Objective-C’ or ‘Hello Swift’ like ‘Hello world’.

As you can see, Swift is much easier than Objective-C.

Getting familiar with X code is a prerequisite to using Objective-C since that’s the integrated development environment you will be building in. So if you have never used Objective-C, but you are familiar with other C-based programming languages such as C# or Java, then it shouldn’t be difficult for you to learn.

Code example of Loop

The for loop might be the most well-known method for iteration over all programming languages. It’s also known as the for-in loop in Swift. Swift provides a variety of control flow statements. These include while loops to perform a task multiple times; if, guard, and switch statements to execute different branches of code based on certain conditions, and statements such as break and continue to transfer the flow of execution to another point in your code.

Swift vs. Objective-C side-by-side comparison ( The pros of Swift )

Swift’s functions and ability is almost the same as the Objective-C language.

So how does it stack up when it comes to performance compared to Objective-C? When Apple introduced Swift 2.0 at the Apple Worldwide Developer conference in 2015, they presented this information.

With such a significantly higher program speed than Objective-C, Swift has to be the clear favorite in terms of developer preference, right?

Also, there are other reasons why Swift is better than Objective-C language.

First of all, Swift is easier to read than the Objective-C language. Because Swift isn’t built on C, it can unify all the keywords and remove the numerous @ symbols in front of every Objective-C type or object-related keyword. You no longer need semicolons to end lines or parenthesis to surround conditional expressions inside if/else statements.

Secondly, Swift requires less code. Swift reduces the amount of code that is required for repetitive statements and string manipulation. In Objective-C, working with text strings is very verbose and requires many steps to combine two pieces of information. Swift adopts modern programming language features like adding two strings together with a “+” operator, which is missing in Objective-C. Support for combining characters and strings like this is fundamental for any programming language that displays text to a user on a screen.

The Cons of Swift Programming Language

It seems Swift is a perfect programming language and there is no disadvantage of using it, but there are some cons. I will explain it to them.

Firstly, it’s limited third-party tooling. Due to its age and version instability, as mentioned before, Swift still lags in the choice of tools helping with certain tasks. Besides, the community reports lots of bugs and issues with the existing software.

Secondly, it’s still young. Although RedMonk called Swift “the growth phenomenon”, you can’t overestimate the importance of maturity for any technology.

Takeaway

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.

Swift has become a more mature language with the latest update, but there are a lot of things to fix. Apple is creating its own ecosystem with a stable ABI over its platforms, but it still lacks tooling and support for earlier versions, which might be fixed in the next releases. Thus, Swift adoption will continue to grow, which soon might lead to the complete displacement of Objective-C as the leading first-class language for iOS mobile application development.

Swift has been years in the making, and it continues to evolve with new features and capabilities. I think Swift will be one of the keys to future technology areas.

--

--

--

Old, Current, and new programming languages.

Recommended from Medium

I let my iOS project turn into chaos.

Custom NavigationView Bar in SwiftUI

Keplr Mobile is now LIVE!

How to Do Swift Dependency Injection Parameter Based

Swift Dependency Injection Parameter Based

Flutter hands on : Building a movie listing app using Flutter (Part 1)

The Pros and Cons of Native Apps

Making a dynamic type-to-tag dialog that’s auto pop up in Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Seattle Web Design

Seattle Web Design

Seattle Web Design Agency

More from Medium

Swift Algorithms & Collections

Journey to became an iOS Developer

Closures in swift

Singleton and Swift