An article aimed to highlight the main beauties that programming language Swift has.
Here I would love to start from a quick quiz.
Question: What is the programming language the iOS apps are written on?
Apparently if you have chosen all of the above - you are 100% correct, all of the mentioned languages are of use when it comes to iOS development. Though, it would not be odd to mention all of them are different due to a huge “generation gap” that separates them.
...Wikipedia states it all has started from an Objective-C, when the granddad of programming languages was launched by Brad Cox and Tom Love back in the early 1980s. Firstly acquired by NeXT, and then, eventually by Apple, when in 1996 they used OpenStep in OS X. Since that time, a huge part of Apple operation system has been developed on Objective-C, and this has been it’s highest rise.
However, as it is well-known, everything good one day makes a great memory, and that’s exactly what is happening to Objective these days. I am 100% sure you have heard of the applications like 2048 game, Wordpress iOS or FireFox iOS browser. Surprisingly enough, the iOS coding language this apps are written on is not Objective - but it is Swift.
Swift. iOS App Programming Language.
(this info was due at the time the article was posted - February, 2017; some changes may apply later on)
In it’s willingness to astonish customers Apple managed to exceed everyone's expectations - particularly developers were more than surprised when in early June, 2014 the new ios app programming language was brought to this world. After 3 years of Swift development, programmers yet haven’t stopped working on it - there have already been several updates, with a latest version of Swift 3.0 released in September 2016. The code written on this open-source language could be applied for macOS, iOS, watchOS, tvOS and (!) Linux.
2 years later now, and Swift has taken a solid position among all the existing mobile development languages. Stack Overflow Developer Survey Results claim Swift to occupy the 3rd place, right after Java and Objective C respectively; more to this, it is gaining its popularity rapidly.
All points considered, are there any advantages that make Swift stand out of crowd? Is there a chance it stands the Swift vs Objective contest?
Swift versus Objective-C
Horses for courses as they say, but there are a few undeniable beauties that Swift-programming-language-from-Apple has. Here’s a bunch of graphically-introduced pros and cons to study.
Even if coding process with all of its hi-tech features seems to be a rocket science to you, the more simple and progressive approach Swift has brought can’t go unnoticed. On the flip side though, there are a few things about Swift that some might call disadvantages, e. g. must use of Xcode as a primary integrated development environment; some developers complain they would better use third-party IDEs that have surpassed Xcode in stability and features.
Reasons For Using Swift
In spite of everything listed before, many development companies worldwide choose to stick to Swift language option, and Mind Studios are not an exception here. Why do we prefer Swift in Objective-C comparison? There are a few easy to consider factors.
Objective-C is already 33 years old and was originally a C-language continuance. In striking contrast, Swift came as a separate language from Apple because it became hard for the company to support and develop Objective. During the 3 years of existence Swift has been actively developed, and the new version 3.1 will soon be delivered.
With a new syntax added up to Swift, it seems way easier to read, compile and inspect the code than it used to be on Objective-C.
As Swift requires less lines of code to be written, then, appropriately, it takes the minimum amount of time to finish the scope of code-creating work.
Earlier in Objective-C, if there was an object-link - it would take some of the random-access memory; when Swift was implemented - Apple left alone object-oriented programming, and switched to structures. As a consequence, the amount of reference type data and SDK classes has reduced, changed for the value type now. This has lead to a more efficient memory usage in Swift.
Swift manages to comply data quicker than Obj-C does; same as Objective-C, It uses the LLVM compiler for optimised native code generation for the platform that it’s running on. In Swift, plenty of arrays are re-written as structures; a few classes used to be objects earlier in Objective-C, which resulted in the slower code working process; although it takes longer for code to compile in Xcode IDE, the code works faster on Swift after all.
6)...not only iOS-oriented.
As was previously mentioned, Swift has already been adapted for Linux, and some programmers have already given it a shot on Android too. In our experience, server part can be Swift-written too.
7)...an open-source language.
Apparently all the technical documentation could be read - which basically means it could be used for the benefit of your future application products. And even more than that - all the willing devs can suggest their resolutions, as Apple has created Jira for Swift bug tracking.
8)… a type-safe language.
In contrast to Objective-C, which never was. Accroding to Stack Overflow’s data, type-safety is not only helpful for run-time, but also for compile-time. Swift does still not check for types at run-time, but does during a check at compile-time which already helps eliminating a lot of errors.
9)...a language with enums, optional types and handy switches.
...which basically means it is a bit safer to use. Objective-C has always been an object-oriented language, but with some structures written for Swift it has eventually led to less crashes and increased safety. Again, Apple have firstly added optional types and then, secondly, enumerations instead of integer values. Optional types help to check the object’s existence within the code, allowing to avoid additional crashes. With the help of enumerations and switches for objects Apple hopes to make coding experience even more mesmerising. An example of Swift enums:
|An example of Swift enums||However, in Obj-C it would be|
|in Swift code they look like||In contrast, here are Obj-C switches|
As it was already mentioned, 4 versions of fresh Swift have already seen the world, and these days we are awaiting on Swift 3.1 to be delivered asap. In addition, rumor has it that the forthcoming Swift 4.0 will have backward compatibility - meaning that integration from the older language versions of 3.1, 3.0, etc. will become easier in the future.
It is all Swift-good.
It would be an unsupported claim if one tried to speak about technology before actually giving it a shot. So judging out of the experience we in Mind Studios already posses - Swift is pretty convenient to work with.
Several of our most recent applications are Swift-written, including:
- Gadh iOS - an app proving online phone and video consultations with your lawyer
- Stern Fit - a social network for passionate athletes
- TapToTrip - a handy route and travel planner
- LIT - premium EPUB eReader
- Unagrande YogaClub - yoga video-lessons for passionate individuals All of the previously mentioned applications involve various technologies, which could be easily implemented on Swift.
Summing it up - which language should you stick to?
This question does not have a universal answer itself. On the one hand, as it frequently happens in IT - the freshest technology is often a solution; on the other, changing your horses in midstream might not be the best-working policy as each project is different. So whatever you decide to go with, just ensure it is a good fit for the business model for this specific market industry and features you have picked out for your future product.
Written by Max Mashkov, Yurii Smirnov and Elina Bessarabova.
Require a consultation which tech to use for your project? Drop us a line!