4

Swift language achieves data-race safety

 6 months ago
source link: https://www.infoworld.com/article/3714341/swift-achieves-data-race-safety.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Swift language achieves data-race safety

Swift 5.10 can enforce full data isolation in concurrent code, preventing threads from reading and writing to the same memory at the same time.

By Paul Krill

Editor at Large,

InfoWorld | Mar 8, 2024 11:00 am PST

shutterstock 1801533685 multiple overhead traffic lights against an evening sky

monticello / Shutterstock

Apple has released Swift 5.10, an update to the company’s open-source programming language that reaches a major milestone: providing safety against data races via full data isolation in the concurrency model. The improvement prepares the way for the planned Swift 6 release.

Binaries for Swift 5.10, introduced March 5, can be found at swift.org for Windows, macOS, and Linux.

In explaining the milestone, Apple Swift engineer Holly Borla said an increasingly important source of undefined behavior is concurrent code that inadvertently accesses memory from one thread at the same time that another thread is writing to the same memory. This unsafety is called a data race, which makes concurrent programs exceptionally difficult to write, Borla noted. Swift 5.10 finally accomplishes full data isolation for concurrency after years of active development. The concurrency model was introduced in Swift 5.5 in September 2021.

Swift 5.10 enforces full data isolation at compile time when the complete concurrency checking option is enabled, Borla said. This sets the stage for Swift 6, which will offer an opt-in Swift 6 language mode that enforces full data isolation by default. In the meantime, Swift 5.10 will produce data-race warnings in some circumstances where code could be proven safe with additional compiler analysis.

0 seconds of 0 secondsVolume 0%

A key focus of language development for Swift 6 is improving the usability of strict concurrency checking by mitigating false positive concurrency errors in common patterns proven to be safe, Borla said. Structured concurrency has been cited as a server-side goal for the Swift language.

Paul Krill is an editor at large at InfoWorld, whose coverage focuses on application development.

Copyright © 2024 IDG Communications, Inc.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK