MacMusic  |  PcMusic  |  440 Software  |  440 Forums  |  440TV  |  Zicos
swift
Recherche

Swift 6 arrives with improved concurrency, data-race safety

mercredi 18 septembre 2024, 22:42 , par InfoWorld
Swift 6, the latest version of the general-purpose language developed by Apple, is now available. The language update features concurrency improvements, including extended safety guarantees for data races. Linux and Windows support and a new testing library are also featured.

Published September 16, the update can be downloaded from Swift.org. For the language and standard library, a new opt-in language mode extends safety guarantees by diagnosing potential data races in code as compiler errors. Data-race safety checks previously were available as warnings in Swift 5.10, introduced March 5. Additionally, there are fewer false positives on Swift warnings due to an improved Sendable inference and new compiler analysis for transferring mutable state from one actor to another. Version 6 also includes a synchronization library for low-level concurrency APIs, including atomic operations and a mutex API. These and other updates in Swift 6 mark the start of a journey to make data-race safety dramatically easier, according to the announcement posted on September 17.

For Linux and Windows, Swift 6 unifies the implementation of Foundation, for accessing data types, collections, and operating systems, across all platforms. MacOS and iOS have used the Swift implementation of Foundation since Swift 5.9, introduced last year. Swift 6 brings these improvements to Windows and Linux. For Linux, Swift 6 offers official testing and support for Debian and Fedora, along with Ubuntu 24.04. Fully statically linked executables are also offered for Linux. And, for Windows, pre-built toolchains are available for the arm64 architecture, bringing improved compiler performance for Windows on Arm hosts. Also in Swift 6, the package manager parallelizes builds across multiple cores on Windows by default, which can improve performance on a 10-core machine by as much as 10 times, according to the announcement.

Swift 6 also introduces Swift Testing, a testing library designed for Swift, including expressive APIs to write and organize tests. Detailed output is offered when a test fails using macros such as #expect. The library scales to large codebases with features such as parameterization to repeat a test with different arguments. Also in Swift 6, a debugging macro is provided to customize how an object is displayed in LLDB when using the p command, and in the variables view in Xcode and VS Code, by using a formatting scheme that does not run arbitrary code. Startup performance is improved in the debugger when using explicit module builds.

Elsewhere in Swift 6:

Productivity enhancements include count(where) to streamline counting the number of elements in a sequence that satisfy a predicate; pack iteration for writing natural for-loops over the elements in a value parameter pack; and access control for imports to keep implementation details for leaking public APIs.

For typed throws, functions can specify the type of error thrown as part of a signature. This capability is useful in generic code that forwards errors thrown in client code or resource-constrained environments that cannot allocate memory, such as embedded Swift code.

For bidirectional interoperability with C++, C++ types that do not have a copy constructor now can be accessed from Swift 6 as non-copyable types using ~Copyable. Swift 5.9 introduced C++ bidirectional interoperability to extend the language’s use to more existing projects.
https://www.infoworld.com/article/3529619/swift-6-arrives-with-improved-concurrency-data-race-safety...

Voir aussi

News copyright owned by their original publishers | Copyright © 2004 - 2024 Zicos / 440Network
Date Actuelle
sam. 21 sept. - 07:31 CEST