Swift 5.7, the latest update of Apple’s Swift programming language, is now available, with usability improvements, a smaller and faster standard library, faster build and launch times, and a new generics implementation.
Unveiled September 12, Swift 5.7 offers language and standard library enhancements including a new shorthand syntax for common boilerplate code, including
if let statements and multi-statement, closure-type annotations. The language’s developers also lifted long-standing language limitations to make generic programming more seamless, and they enhanced data race safety with new annotations and opt-in diagnostics. New language support and APIs are offered for string processing. Yet another language improvement is actor isolation in distributed environments.
For generics, the type checker’s generics implementation has been rewritten, providing improvements to performance and correctness. With certain configurations of protocols and associated types, type-checking time would increase exponentially in Swift 5.6 but now increases only linearly in Swift 5.7. Swift’s new generics implementation fixes many longtime bugs, mostly related to handling of complex same-type requirements, such as those on a collection’s
SubSequence associated type, and code using the
CaseIterable protocol, which defines the requirement,
Self.Element == Self.
Swift binaries can be downloaded from swift.org. Other new features and improvements in Swift 5.7:
- Automatic reference counting is more user-friendly, predictable, and performant, through specifying new rules to shorten the lifetime of variables when optimization is permitted. To enforce the new rules, the compiler adopted a new internal representation that tracks the lexical scope of each variable.
- Code completion of function call arguments, global functions, and variables now is tightly integrated into the Swift type checker, allowing code completion to offer more accurate results inside ambiguous code or code with errors.
- The Windows toolchain has fully adopted swift-driver as the compiler driver. The C++ driver no longer is packaged or provided as a fallback. Also for Windows, the installer has been improved for deploying module-maps and packaging files, reducing the size of the installer download.
Copyright © 2022 IDG Communications, Inc.