Apple’s Swift 5 takes shape
21 August 2017 | 0
Version 5 of Apple’s Swift language used for iOS and MacOS application development will arrive in late 2018 with application binary interface (ABI) stability in the standard Swift library a primary focus—delaying a feature originally intended for the upcoming Swift 4 release.
Locking down the ABI in Swift 5 will mean any future compiler versions can produce binaries that conform to the stable ABI. “Once an ABI is stable, it tends to persist for the rest of the platform’s lifetime due to ever-increasing mutual dependencies,” according to Apple documentation.
This stability only affects invariants of externally visible public interfaces and symbols. Internal conventions, symbols, and layouts can keep changing without breaking the ABI. Compilers, for example, are free to change calling conventions to internal function calls as long as public interfaces are preserved.
Decisions about the ABI are serious business, with long-term ramifications and possible limitations on how the language can evolve. But ABI stability means that operating systems can embed a Swift standard library and runtime compatible with applications build with both newer and older versions of Swift. The applications thus do not need to distribute their own copy of these libraries.
ABI stability is half of what is needed to support binary frameworks. The other half, module stability, will be a “stretch goal” for Swift 5 and may not make it into the release, Apple’s roadmap notes.
Carryover goals from Swift 4 that are prerequisites to locking down the ABI in Swift 5 include:
- Generics features for the standard library, including conditional conformances for generic types and recursive protocol types, lifting restrictions on associated types in protocols.
- API resilience, allowing public APIs for a library to continue to evolve.
- A memory ownership model, which will be partially introduced in Swift 4. Swift 5 will add pieces key to ABI stability to the Swift 4 memory model.
Aside from ABI stability, Apple expect the following improvements in Swift 5:
- String ergonomics , to improve processing of the string type. This could include new text-processing capabilities as well as language-level backing for regular expressions.
- Groundwork for a new concurrency model—but finalising this model is not a goal for Swift 5. A key focus area will be designing language capabilities for building and using asynchronous APIs and dealing with problems created by callback-heavy code.
- Minor additions to the standard library.
- Targeted improvements to the Foundation API so the Cocoa SDK can work seamlessly with Swift. (Cocoa was originally designed for Objective-C, which Apple has been phasing out for three years.)
- Syntactic additions, with assessments to be done on degree of positive impacts.
IDG News Service