The need to switch to Swift, Apple’s new programming language

Objective-C and the beginning of iOS programming

App stores creation provoked an explosion of programmers only for this kind of applications. The first iOS developer kit appeared in 2008. It used Objective-C as its programming language.

Objective-C was adopted by Apple to develop OS X applications and later on rescued by Steve Jobs during his stage in NeXT. Until that moment, Objective-C presence was merely anecdotic as well as developing using Xcode (Apple’s IDE for developments).

At that time, memory management was completely manual, sintaxis as a language was too explicit and long. Besides, and probably the most negative aspect when it came to the user, was that the structure gave programming problems that caused sudden unexpected errors.

A lot of developers used Java and C# libraries without focusing or taking into consideration special aspects of the system.

With iPhone OS developing kit (that later would be known as iOS), Apple introduced a lot of language improvements. Some of these examples are the reduction of language implementation and the incorporation of ARC (Automatic Reference Counting), an automatic system of memory management that let you forget elements that were no longer interesting.

Apple has also improved its IDE adding new functionalities and libraries in order to enrich iOS and Objective-C possibilities. Even though, statistically, iOS applications were less stable than Android’s. That did not mean that Android apps were better, it only stated that Android’s programming language (Java) was far safer when it came to programming errors.

When developing a program, one has to be careful not to make mistakes. Especially, errors that shut our app down unexpectedly need to be avoided. If programmers wants to avoid this, they need to follow good practices and keep their code as clean as possible. Not all programmers apply these working methodolgies. When a language does not forsee errors like these, they will ultimately show when the programmer reaches them, but no sooner. And probably it would be too late and the app will already be down.

The biggest problem with Objective-C is that it delegates the major part of the work to programmers, giving them all the responsibility when it comes to error check while programming, which has to make them methodic when working.

Apple needed to fix this aspect. The solution came last year at the Anual Apple Developers Conference. Swift had just landed.

Screenshot during development with Swift

Swift

Swift is based on the idea of creating a modern, safer and more superior language than Objective-C, where the majority of errors that were not previously controlled are transferred to coding and compiling.

Empty pointers, buffer overflows, unused variables, ambiguous references... All the errors that a programmer could trigger using Objective-C are now taken over with Swift, giving nearly full responsibility to language.

Moreover, Swift incorporates all the elements of a modern language that identifies where and why the code is failing. Where performance and optimization of the language goes a step further that Objective-C could not reach, relieving compilation with new programming flows such as generic ones and functional programming.

When something is not working and can’t evolve, it’s better to start anew and check the basis of it so you can have safer and more efficient developments in the future. And that’s exactly what Apple did with its programming language.

Apple defines Swift as a modern and flexible language that introduces new programming concepts that have recently appeared in other languages like Python or Ruby and even older and more complex such as Haskell.

It is also defined as a mix between C and Objective-C but without compatibility restrictions.

Swift is a language based on escripting languages with a high level power that uses tools such as generics, optionals, structures, tuples, functional programming and more. A language that later this year will become open source and, presumably, will also have compilers for Linux systems that will facilitate its expansion.

Swift is more potent and lighter than Objective-C being a super class of C. That makes it have less layers of compilation so it doesn’t hinder performance and improves the quality of the code generated.

Swift is positioned at an intermediate position between the lightest languages like Ruby, Python or Lua, where they are productive but also inefficient by the number of compilation layers that they require (they are designed to work at a higher level). And among the other more potent languages such as Objective-C, C # and Java, which are closer to machine code but, instead, require more coding, components are more complex when it comes to getting the results you require.

Swift is somewhere in the middle as it is very similar to a escripting language but, at the same time, it is very close to machine code, thus enjoying the characteristics of the two groups without taking the drawbacks.

Screenshot during development with Swift

Swift programming

Swift programming improves performance and positions it in an area where the language evolves and improves with a higher quality code avoiding shut downs and unexpected errors.

Initially, Swift may seem difficult to understand because it seems cryptic although it is less semantic than Objective-C and, once used to its syntax, is much more optimal for work. Besides, it also provides developers with lots of possibilities through new structures taken from other languages and allows them to forget elements than can manage themselves and reach levels that could not be achieved so far.

Swift has lots details that make software even safer, such as optional variables in order to empty values, the obligation to initialize variables or contemplate all the possibilities of a program flow.

All this means more safety when developing and quality assurance and ease, as many of the problems are transferred to the language saving time to programmers.

Do not forget that when developing using Swift, programmers can use libraries and classes that they usually use and are found in Objective-C. Step by step, Apple is migrating all its libraries to Swift making it, in turn, safer and more agile. In addition, Objective-C has been improved with the release of Swift embracing the idea of non-nulles or generic variables.

Apple is betting all the cards to Swift and going a step further into the world of programming and software development.

This site uses cookies to provide you with a better browsing experience. By continuing browsing we understand that you accept the Use of cookies. Modify your configuration
Cross cookies