The Swift language is based on Objective-C, which was used for NeXTSTEP development in the 1980s, and later macOS and iOS. Swift has similar syntax and maintains the object-oriented features of Objective-C, but provides a more simplified programming experience. For example, Swift code is easier to read and write than Objective-C. It allows several common commands to be combined and does require semicolons (;) at the end of each statement.
Additionally, Swift handles several programming obstacles automatically. For example, Swift:
- initializes variables before they are used
- handles "nil" (NULL) values explicitly
- ensures array indices are in bounds
- prevents integers from overflowing their allotted memory
- manages memory automatically
Apple's Xcode software development IDE has supported Swift since version 6 (released in 2014). Xcode also supports "Swift Playgrounds," a feature that allows programmers to edit Swift code and see the results immediately. For example, the playground may display the source code on the left and an app simulator on the right. Changes to the code update the app simulation on-the-fly. Several playgrounds are included with Xcode to provide an easy way to learn the language.
Since Apple develops and maintains the Swift language, it is optimized for Apple hardware. Therefore an iOS app developed in Swift may perform better than a similar app developed in another language. Apple also updates Swift with new features on a regular basis. This allows developers programming in Swift to take advantage of the latest advances in Macs, iPhones, iPads, and other Apple products.
File extension: .SWIFT