One of the most surprising announcements of the WWDC14 was Swift, the new programming language for Cocoa and Cocoa Touch. I have to say I was really excited about the new language, even though I had some doubts at the beginning, mainly due to it’s python-like syntax and it’s use of emojis. I still think that including emojis as possible variable/structure names is not a smart move, as it will no doubt attract even more 15 y.o teenagers that don’t really want to learn to program, but just copy&paste code from stackoverflow until they release the next angry birds or flappy bird clone. Maybe that’s what Apple wants.

Thanks god my second mistrust was unfounded. Swift is a tight, serious language, with structure, enclosing brackets (thank you Apple!), and strongly typed. While I was studying it, the more I did read about the language, the more I liked it. I think Apple has done a great job cleaning the clutter and defining a fresh, clear language. It is also nice to know that you can seamlessly merge Objective-C and Swift code in the same project. But one of the best moves from Apple (in my opinion) is improving the language thanks to the developers’ feedback, as if it was the MVP of a new startup.

Last version of Xcode, 6 beta 3, includes some changes in Swift, namely:

  • Array has been completely redesigned to have full value semantics to match the behavior of Dictionary and String. Now a let array is completely immutable, and a var array is completely mutable.
  • Syntax “sugar” for Array and Dictionary has changed. Arrays are declared using [Int] as short hand for Array<Int>, instead of Int[]. Similarly, Dictionary uses [Key: Value] for Dictionary<Key, Value>.
  • The half-open range operator has been changed from .. to ..< to make it more clear alongside the operator for closed ranges.

I think all these changes allow to define arrays and dictionaries in a simpler and easier way, and also eliminates some ambiguity about their mutable/immutable nature.

I can really see Swift evolving and improving with each beta until being a really mature programming language for the official release of iOS 8 and OS X Yosemite this fall.