Swift language is a relatively new programming language, presented by Apple during WWDC 2014.
If I were to choose one pro and one con about this language I would choose:
Pro: safety by design.
All java developers are aware of the java.lang.NullPointerException, calling a method on a non existant object will throw an exception. To prevent that we have to check if an object is null or not before trying to access it.
In Swift this kind of exceptions is virtually impossible as long as you respect some principles.
We distinguish two kind of variables:
- non optional one
A non optional variable can't have a nil / null value, this is checked at compilation time.
An optional value is basically a wrapper given access to a non optional variable. This wrapper can be nil / null. Using the linked value requires an unwrap operation. As long as you don't use a forced unwrap you will never be able to use the linked value if it is non-existant.
Objective-c, another language used for programming on Apple's device, is also quite, but less, resilient to those kind of errors as calling a method on a nil object does nothing and return a nil value.
Con: ABI not stabled yet.
[Edit]: The above was true at the moment I wrote this articule, fortunately it isn't anymore as Swift is now stable enough since version 5.
As the language isn't considered as being finished yet, many libraries used by it aren't included in the Operating System yet but are included in the application package: • This allows an application to keep running after the release of a new version of swift without having to fix compatibilities issues. • This implies that a swift application weight many MB more than it's Objective-C equivalent. When your application is quite heavy by itself it isn't really important, when it is a small utility one, like Astro Kit, this is a real issue.
For references, I tested rewriting Astro Kit from Objective-C to Swift and the result was a definit no go. Going from less than 1MB to more than 20MB wasn't acceptable at all as I keep thinking that an application should be as light as possible.
Hopefully will the release of Swift 5 planned for 2019 the language will be stable enough for the library to be included directly on the OS.