Paul Krill
Editor at Large

Swift language concurrency model proposed

news
Nov 6, 20202 mins

The ‘first-class’ concurrency model would make asynchronous programming in Swift convenient, efficient, and safe, according to a roadmap outlining the plan

women spinning plates asynchronous programming synchrony multi tasking by graemenicholson getty ima
Credit: graemenicholson / Getty Images

Plans are afoot to outfit Apple’s Swift language with a “first-class” concurrency model. The goal is to make concurrent programming in Swift efficient, safe, and convenient, according to the roadmap published at forums.swift.org.

Swift concurrency is intended to prevent data races on mutable state by default, through the implementation of asynchronous functions and actors. These will be introduced in two phases, first by bringing in the ability to create async functions and actors, and then by enforcing full actor isolation. 

The end state of the proposed changes would do the following:

  • Eliminate data races and deadlocks in the same way Swift eliminates memory unsafety.
  • Make asynchronous programming convenient and clear at its point of use.
  • Provide a standard set of language tools and techniques that developers can follow.
  • Improve performance of asynchronous code through better knowledge at compile time.

The introduction of these features would span multiple Swift releases. The first phase, introducing the async syntax and actor types, would allow users to organize code around actors in such a way that would reduce but not eliminate data races. The second phase, which would enforce full actor isolation, would eliminate data races. It also would offer features allowing efficient, ergonomic interoperation of actors needed to make the isolation practical.

Specific proposals for the first phase include:

  • Introduction of a coroutine-based async/await model to Swift.
  • Task API and structured concurrency, introducing the concept of a task to the standard library.
  • Actors and actor isolation, describing the actor model that provides state isolation for concurrent programs.
  • Concurrency interoperability with Objective-C, Swift’s predecessor language.
  • Async handlers, introducing the ability to declare a synchronous actor function as an asynchronous handler.
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