Paul Krill
Editor at Large

Swift language speeds standard library, reworks generics

news
Sep 14, 20222 mins

Swift 5.7 features a smaller and faster standard library, usability improvements, and a new generics implementation that boosts performance and removes long-standing bugs.

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.
Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author