Tagged: Programming

Apple’s new Swift Programming Language

SwiftLogo

Apple has released a new language to program iOS and OSX Apps called Swift. Over the last weekend I took sometime to go through A Swift Tour section is Apple’s free iBook on the subject. It’s roots are definitely in the semantics of Objective-C, but you get the full modern day benefits of languages like python and javascript. You can do more with typing less. It’s more like a scripting language.

The real progressive part though is that it achieves less typing, by using implicit types. For example

var myDoublePrecisionNumber = 0.007 # This will be implicitly define the type as double
var myExplicitPrecisionNumber : Double = 0.007 # This will explicitly define the type as double

The first and obvious advantage is that it requires less typing, but the secondary and really neat advantage is that once implied, if a calculation assigns the value that would convert the value to a type that would be detrimental to the program, the compiler will warn or error appropriately. Catching errors, like in javascript and python, at runtime is much more ‘expensive’ in time than at compile time.

If you would like to see my solutions to the ‘Experiments’ in a A Swift Tour you can find all the code in that section is the playground file stored in a gist on github