The Comparison Between Swift and Objective-C Programming Language

Swift programming language has been announced and released on XCode 6 Beta for over 2 months. Although it is not out of the Beta version yet, we (the iOS mobile Developers) could get our hands dirty on the playing with the Swift code to understand the differences between the Swift and Objective-C Programming Language.

Let’s us make some comparisons between Swift and Objective-C and understand the differences between these 2 programming languages. We can also identify the strengths of Swift over Objective-C.

Swift Programming Language and Its Development

Swift Programming Language is been developed by Chris Lattner and his team since year 2010. He is the director of the Apple Developer Tools such as Xcode, the Instruments and the compiler. As of year 2014, it has been in the development for 5 years.

Steve Jobs passed away on late 2011. The development of Swift has started more than 1 year before Steve Jobs’s passing. It means that Steve Jobs could have involved in part of the Swift Language Development. There is a chance that it is Steve Jobs’s vision that a new and powerful programming language is needed to replace Objective-C (a 30 years old programming language). Only the internal development team could verify if this is a fact or just a random guess.

From watching the WWDC videos on Swift, we understand that Swift is designed to be more

The syntax for Swift is designed so that the programmer/developer could make less erroneous codes. When there is any problematic code, the error/warning inside the text editor of the XCode will be much clearer that forces the programmer to correct the mistake. When we program using Swift, we will also write lesser lines of codes when comparing with Objective-C. For example, there is no need of semicolon “;” at the end of each line of code. A few powerful features such as Extensions have been introduced on Swift to ease the developer to create great apps in less time.

The Differences of Swift and Objective-C Code Syntax

Let’s compare the differences between Swift and Objective-C Programming Language. Let’s learn what makes Swift a better programming language.

I have used NSDictionary, NSMutableDictionary, NSArray and NSMutableArray quite extensively on most of my iOS project. So, let’s start to compare these syntax.

Dictionary and Array in Objective-C versis Swift

Objective-C Code

Swift Code

From the above Objective-C and Swift codes are doing exactly the same thing for Dictionary and Array declaration and initialisation. With just the First glance, I believe that you will realize that the code for Swift is simpler and also short.

Check Out the complete documentation for Swift Programming Language: Swift Programming Documentation by Apple.

How to Use Auto Layout in XCode 6 for iOS 7 and 8 Development
Swift, Home Automation and Indoor Positioning System


  1. checkmate says:

    var accessories: [HMAccessory] = []
    how can i write about statement in objective c?

    • Hi,
      It should be something like:-

      NSMutableArray * accessoriesArray = [[NSMutableArray alloc]init];

      HMAccessory * hmaAcessory1 = [[HMAccessory alloc]init];
      HMAccessory * hmaAcessory2 = [[HMAccessory alloc]init];

      [accessoriesArray addObject:hmaAcessory1];
      [accessoriesArray addObject:hmaAcessory2];

  2. You used the quick array implementation in swift but not in objc? @[]

  3. Thank you for sharing your article. This is very informative article to Swift and Objective C programming languages.
    Keep it up.

Speak Your Mind