Swift 5.5 Adds Concurrency Support
Written by Kay Ewbank   
Tuesday, 05 October 2021

Swift 5.5 has been released with new features for asynchronous code and concurrency including async/await, structured concurrency, and Actors.  Swift is Apple's language that was originally developed as an alternative language to Objective C.

Swift's designers aim is to provide a single language including the best ideas from languages such as C# and JavaScript, while being easy to use. It was made open source by Apple in 2015, and a Linux build was added at that point.

swiftlogo
 

The improvements to Swift 5.5 start with support for coroutine models to make it easier to write asynchronous code. The developers say a lot of Swift code involves async programming using closures and completion handlers, but these APIs are hard to use. To overcome this, the new coroutine model means functions can opt into being async, so developers can have asynchronous operations using the normal control-flow mechanisms. The compiler is responsible for translating an asynchronous function into an appropriate set of closures and state machines.

Another improvement is the addition of structured concurrency. This uses the async/await improvements, and adds the ability to execute, cancel, and monitor concurrent operations in Swift. The asynchronous functions introduced with async can give up the thread on which they are executing at any given suspension point, but they don't actually introduce concurrency. This has been added separately to provide a way to support concurrent execution of asynchronous code. Structured concurrency relies on tasks being split into high-level tasks and their child component tasks.

Other improvements add support for creating and awaiting child tasks using the simple syntax async let as an alternative to task groups; and support for package collections to the Swift package manager, SwiftPM. A package collection is a curated list of packages and associated metadata. SwiftPM now lets you subscribe to these collections, search them via the swift package-collection command-line interface, and makes their contents accessible to any clients of libSwiftPM.

Swift 5.5 is available now.

swiftlogo

More Information

Swift Org

Related Articles

Swift 5.2 Improves Performance

Swift Adds More Generics Support

Swift 4 Improves String Handling

Swift 3.0 Released!

Apple Launches Swift Playgrounds

Apple Open Sources Swift

Apple's New Language - Swift       

Swift 2 To Be Open Source       

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Chainguard Joins Docker Verified Publisher Program
15/03/2024

Chainguard has joined the Docker Verified Publisher (DVP) program, meaning its Chainguard Developer Images are now officially available on Docker's container image registry.



We Built A Software Engineer
20/03/2024

One of the most worrying things about being a programmer today is the threat from AI. It has gone so far that NVIDA CEO Jensen Huang proclaims that you really shouldn't start training as a programmer  [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 05 October 2021 )