This week was the most expected by the Apple developers: we enjoyed the WWDC 2014 and the new (and dramatic!) changes that are coming with the next version of iOS (iOS 8).
One of the most striking changes was the release of a new language that will coexist (replace?) with Objective-C: SWIFT. Do we really need a new language in order to make things better? Not sure, but it is supposed that SWIFT will bring new changes, a easy way to develop iOS Apps and performance improvements, so it is time to try it out and see how powerful it is.
Some of the key features of Swift vs Objective-C:
- Playgrounds, a way to see in real time what we are doing during the development process.
- ARC Support
- Co-existing with Objective-C
- Backed by Cocoa and Cocoa Touch
- New types (Int, Double, Float…abstracted as typical OO classes)
- Keywords “let” and “var” will be used for defining variables and constants.
- Methods and functions can return tuples for retrieving N values at the same time instead of the typical single result. It improves the limitation of retrieving a single result in one register of the processor (remember EAX? )
- Assertions – typical use for unit testing-
- Two main structured types: Arrays and Dictionaries
- Typical flow control instructions (if, for, while…). Switch-case sentences are more powerful as they can select a case inside an interval. Really interesting…
- New structure for functions.
- Class and Structures support: the first one support heritage, type casting and deinitializers – used when resources should be freed, as opposite to initializers-.
- Subscripts – similars to functions / shortcuts-.
- Heritage support – subclassing and overriding of methods and properties-.
- Initializers and Deinitializers invoked when creating and destroying object instances.
- Extensions, allow us to enlarge the functionality of any class or even of any native type!
- Protocols support
Well, there are a lot of new features, at the moment these are the most relevant, but Apple has released a free book in iTunes (The Swift Programming Language) to have the first touch with Swift. Now it is time to try it out and move some projects to support iOS 8, so…good luck!