6 Main features of Swift Language that makes it Game Changer
Apple just have announced its new language Swift for iPhone application development. Swift is a way to write iOS and OSX applications. Swift is endorsed by the existing cocoa framework. It has highly optimized compiler to enhance its performance and to optimize development aspects. Considering the scale of application that developer can create using swift language, application can be scaled from “Hello World” program to entire operating system. Looking to the new features of swift language it seems to be game changer.
Following is the main features of swift language that makes iOS application so much optimized, powerful and enhanced.
1) Supports playground:
It is one of the main features of Swift Language that has been added to xCode. With playground feature, developer can write the code separately and test it out without hampering other existing code. Developer can see the result of playground code without running whole application, so it saves time for development. It is very much important if developer wants to test the code (project module) without hampering other existing codes.
2) Type Inference:
Till now it was mandatory to explicitly mention data type for variable. With type inference add-on main features of swift language it is not mandatory to write data type for each variable. It explicitly catches data type of variable using initial value that developer has assigned.
Example 1 : Variable “pc” is Int type variable as explicitly data type mentioned in declaration.
var pc:Int = 10
Example 2: Variable “pc” is Int type variable as integer value has assigned to it.
var pc = 10
3) Type safe language:
One more main features of Swift language is, it is type safe language. It prevents passing different data type value to different data type variable. It catches exception at compile time itself if it finds any conflict in data type. So it reduces run time overhead ensue of this application runs faster. It also reduces run time application crashing.
4) Optional data type:
Optional data type is used when value to the specific variable is absent. This data type variable may have value or no value. It is very much relevant to “nil” key word in objective-c. But there are some difference between optional data type and “nil” keyword, that makes optional data type special. One of the difference is “nil” keyword doesn”t work for certain object like struct.
5) Unicode support:
Unicode character consists of almost all the characters in each and every native language.
Earlier variables and constants name we were using has its own naming conversions like variable should not content special characters or it should not start with integer value. But in Swift programming language, even developer can use Unicode character for variables and constants naming convention.
6) Collection Types:
It supports two types of collection objects. One is array and another is dictionary. Both array and dictionary are used to store multiple object having same data type. Array contents object in ordered manner, where as in dictionary objects get stored in unsorted manner. Dictionary have objects and each objects has its corresponding key. Stored data objects in dictionary are accessed by using key.
I am exploring and learning iOS swift language and above are the main features of swift language that I came across while exploring. I will come with more add-on main features of swift language and will let you know. Feel free to comment if you think any main features of swift language that we should have to mention here.