Apple released Swift on WWDC 2014. We can build apps for phones, desktops, servers or anything else with Swift. It combines most modern programming approach from Apple’s engineering team and open-source community. It is highly optimized for performance and development. In WWDC 2015 Swift made a major upgrade to version 2.0. It’s made open source and licensed under Apache 2.0. And now in June 2017, Swift holds 12th rank in TIOBE index which shows the popularity it has gained within a period of 3 years.
As a developer, it was very difficult to use Swift at the early stages. They kept on changing the syntaxes with every update they had. And now with Swift 3, it is very stable and friendly.
Given below are some of the benefits of Swift compared to Objective-C:
- Swift maintain a clean syntax which makes it easier to read and write. Number of lines of code needed for implementing something in Swift is very less compared to Objective-C.
- They no longer need semicolons to end statements.
- Another one is Method calls are not nested within square brackets [[[…]…]…] anymore.
- In Objective-C, there were high chances of crashes while dealing with null values. The developer has to think of all possibilities and handle them all. But Swift is safe. It’s very easy to handle Null pointers in Swift compared to Objective-C.
- Code quality, Swift helps you to write better, less buggy code that’s the most important reason of all to use it.
- The optional type was introduced in Swift. If there are some chances of null values in code, we can use optional type in Swift. The compiler will generate errors if the developer does not handle optional correctly.
- Also, it’s easy to maintain swift code. Earlier in Objective-C, there were .h and .m files for faster build time. The developer needs to synchronize method names and comments throughout them. Now we have only a single file in Swift.
Xcode and the compiler does all the rest for us. Thanks for that.
- Swift comes with newly introduced Playgrounds tool. It makes a lot easier for the developers to test their codes or algorithms without creating an entire project. It supports inline execution of code and developers can see the result as they type.