Swift is an innovative programming language from apple. Swift has been introduced along with the release of iOS 8 and Yosemite. It offers a very faster and easier way to build iOS applications than its existing programming language, Objective-C.
It is a multi-paradigm programming language.Apple describes Swift as modern, fast, powerful, safe and interactive programming language.
swift_tut
If you have knowledge in object oriented and functional programming, you can learn it easily.Swifts’s syntax is much more succinct and it makes programming simpler .The code is clean, simple and less vulnerable to errors.

Comparison between Objective C and Swift

Swift offers type inference by introducing ‘Var’ keyword, while ObjC does not. Another main feature of Swift is generics but objective C does not have this feature. With Objective-C developers often needed to find separate codes from other libraries but in Swift you can find a lot of functional codes built in.

Here are some comparisons between some equivalent operations in Objective-C and Swift:

Let’s start with “Hello World”

Swift

Objective C

One thing you may noticed that there is no semi colon(;) at the end of swift statement. Swift doesn’t require you to write a semicolon at the end of each statements.

Variables and constants declaration

In swift we declare variables with the ‘var’ keyword and constants using the ‘let’ keyword.

Example :

Swift:

You can specify type information when declaring a variable in Swift

Eg:

If you declare a string as “var”,the string can be modified.There is no separate NSString and NSmutableString classes.

Objective C

One interesting thing in swift is that it allows you to use emoji character for the naming 🙂 .

The syntax of declaring an array and dictionary in Swift is almost similar to that in Objective C.There are no “mutable” counterparts toArray and Dictionary. Instead, you use the standard ‘let’ and ‘var’.

Swift:

Array:

Dictionary:

Objective C

Array:

Dictionary:

Another innovative feature introduced with swift is ‘Playground’.It is a great tool for running snippets of code in real time without compile the entire project.

Steps to integrate playground

  1. Select a .playground file in the project navigator, or create a .playground file by choosing File > New > File and selecting the Playground source template for your platform.
  2. Enter Swift code into the .playground file, and you can see the results in the sidebar as given below.

 

playground

Swift has so many amazing features that make it better than Objective-C. It’s syntax is more developer-friendly unlike objective c with weird syntax and it is easy to learn. It is an inspiration to people from other programming background to learn iOS programming and build iOS apps. Objective C will not be deprecated any time soon but in future Swift may completely replace Objective-C.