Saturday, 24 January 2015

HB Blog 54: Objective-C And(not VS) Swift.

I have been thinking a lot about the right tile for this post. Objective-C And(not VS) Swift sounds more
informative rather than comparison and differences. Afterall, we don't prefer to discriminate on basic of
languages.

Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. It is the main programming language used by Apple for the OS X and iOS operating systems, and their respective application programming interfaces (APIs), Cocoa and Cocoa Touch.

Swift is a multi-paradigm, compiled programming language created by Apple for iOS and OS X development. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products.

There many similarity between both of them as follows:-
1)Both are used by Apple.(I need not brief on that context.)
2)Both have same basic numeric types (Int, UInt, Float, Double).
3)Both use curly braces to group statements.
4)In both, variables are assigned using an equals sign, but compared using two consecutive equals signs.
5)In both, control statements, for, while, if, switch are similar.
6)In both, class methods are inherited, just like instance methods, self in class methods is the class the method was called on.

But,they both have few differences too,
1)In Swift, statements do not need to end with a semicolon (;), though they must be used to allow more than one statement on a line
2)In Swift, header files are not required
3)In Swift, functions are first-class objects.
4)In Swift, enumeration cases can have associated data (algebraic data types).
5)In Swift, operators can be redefined for classes (operator overloading), and new operators can be created.
6)In Swift, strings fully support Unicode. Most Unicode characters can be used in either identifiers or operators.
7)In Swift, no exception handling (though it can be emulated through use of closures).
This is not seen in Objective-C.

No comments:

Post a Comment