Rust 1.39 Gets Async-Await
Written by Ian Elliot   
Friday, 08 November 2019

The latest version of Rust adds async-await for easy asynchronous programming and Microsoft thinks the language could be an alternative to C++.

While a lot of people want to talk about Go, it is Rust that is really offering something new and it deserves to be the hottest language that is around at the moment. That Rust isn't claiming the limelight  is perhaps because we tend to see new as difficult and it is true that the learning curve for Rust is steeper.

It is often claimed that strong typing is the key to bug-free programming - well fewer bugs at least - but Rust's use of ownership really does cut down the bugs.

New in version 1.39 is async-await support and while this might not reduce bugs in async code it makes it much easier to write and this has to have an effect. Async-await is a high-level approach to waiting for operations to complete. It does away with callbacks and other round-about methods of resuming execution by making it possible to explicitly resume execution. Rust does this in a slightly different way to JavaScript and C# - the two best known languages with async-await.

What you do is declare a function to be await-able using async:

async fn myFunction()

When you call an async function it doesn't do the computation. Instead it returns a Future which is the computation but in a suspended state. To start the computation all you have to do is use the .await operator:

let myFuture = myFunction();

In this sense Rust's Futures are lazy - they don't execute until you await them. It is claimed that async-await integrates well into the "borrowing" system, which is how Rust shares objects between owners.

With the adoption of the async-await approach to asynchronous programming, Rust again emphasizes the fact that it is trying to be a modern language. It may be a language that has a lot to do with Mozilla, but Microsoft seems to be keen to give it a fair trial after discovering that most of the bugs they have to deal with are due to memory allocation errors. You have to try quite hard in Rust to create this sort of error and hence it makes a good replacement for C++.

Adam Burch, Software Engineer, Hyper-V team writes:

"This blog describes part of the story of Rust adoption at Microsoft. Recently, I’ve been tasked with an experimental rewrite of a low-level system component of the Windows codebase (sorry, we can’t say which one yet). Instead of rewriting the code in C++, I was asked to use Rust, a memory-safe alternative. Though the project is not yet finished, I can say that my experience with Rust has been generally positive. It’s a good choice for those looking to avoid common mistakes that often lead to security vulnerabilities in C++ code bases."

The only real negatives mentioned are omissions:

"Given Rust’s relative youth, there are still some missing language features that would be very desirable for our development. Foremost of these are safe transmutation (safely cast “plain old data” types to and from raw bytes), safe support for C style unions, and fallible allocation (fail gracefully from allocation failure, rather than panic)."

There are also some shortcomings in the unit testing abilities of Rust's Cargo.

It will be interesting to see how Rust fares in the longer term as an alternative to C++ which is deeply entrenched at Microsoft as it is what most of Windows is written in.



More Information

Async-await on stable Rust!

Announcing Rust 1.39.0

Using Rust in Windows

Related Articles

Is Rust Really Safe?

Rust Improves Tracing

Oxide - A Simpler Formalized Rust

Eclipse Photon With Full Rust Support

Rust 2018 Released To Improve Developer Productivity

Rust Survey Revelations

Rust 1.28 Improves Memory Use

Rust 1.26 Adds Existential Types

Rust 1.24 Adds Reformatter

Rust 1.23 Uses Less Memory

Rust Hits Stable 1.0 - So What?

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.



OpenSilver 3 Adds AI-Powered UI Designer

OpenSilver 3 has been released with an AI-powered UI designer and support for VS Code. The open-source alternative to Silverlight is capable of running large, complex legacy applications, as well as n [ ... ]

Amazon Updates Q Family And Previews App Studio

Amazon made multiple announcements at its AWS Summit in New York, including a preview of AWS App Studio, the addition of Q Developer to SageMaker Studio, and an Amazon Q Apps API.

More News

kotlin book



or email your comment to:




Last Updated ( Wednesday, 22 July 2020 )