Microsoft Offers Rust For Windows
Written by Mike James   
Monday, 19 April 2021

Rust seems to be the great saviour of programming at the moment and Microsoft is the latest to jump on the bandwagon with Rust for Windows.


I'm not saying that jumping on the Rust bandwagon is a bad thing, but Microsoft makes an interesting travel companion. In the recent Microsoft world there were only two languages - C++ as a systems programming language and C# for everything else. After the Windows 8 meltdown Microsoft became omnivorous when it came to languages - adopting JavaScript, Python and anything that came into view.

The question remains if Rust is just another language to add to the collection Microsoft thinks are OK to support. For example, there is the Get Started with series of tutorials - Get Started with - Python, Node.js, Android, C++, C#, Docker, PowerShell, Database and now Rust. However, in the middle of all of this is that piece of news that we now have Rust For Windows. This isn't just using Rust to develop some generic console program, but a project to present the Windows API to a Rust program via the windows crate. This seems to include everything from basic windowing functions to Xaml. This is all possible because of the Windows metadata project, which describes the API in a machine readable form which can automatically be converted into Rust:

That Microsoft might have a play around with Rust isn't a surprise, but this is the first time Microsoft has shown affection for a language that could replace C++ in building Windows and  many Windows tools and applications. There has been much recent talk about letting Rust into the Linux kernel, could it be that the Windows team is thinking the same thoughts? If past experience is anything to go by, they are probably closing ranks and defending C++ a vigorously as possible - still doesn't mean it won't happen.

On the other hand, you have to be slightly sad to see the first example on the Windows Rust site. It starts well enough:

fn main() -> windows::Result<()> {
    let doc = XmlDocument::new()?;
    doc.LoadXml("<html>hello world</html>")?;
    let root = doc.DocumentElement()?;
    assert!(root.NodeName()? == "html");
    assert!(root.InnerText()? == "hello world");

but then we crash into:

unsafe {
     let event = CreateEventW(std::ptr::null_mut(),
true, false, None); SetEvent(event).ok()?; WaitForSingleObject(event, 0); CloseHandle(event).ok()?; MessageBoxA(None, "Text", "Caption",

There is little point in adopting Rust if you are going to have to resort to "unsafe" the first time anything looks tricky. Is Rust for Windows able to avoid unsafe enough of the time to make it worth considering. Interesting question...


More Information

Rust for Windows, and the windows crate


Related Articles

Google Supports Rust For Android OS Development

Is Microsoft Planning To Replace Rust?

Rust 1.46 Adds New APIs

Amazon AWS Invests In Rust

Mozilla Layoffs - The Fallout

Rust Is A Top Twenty Language

Daily Rust Use Increases, Survey Finds

Rust 2018 Released To Improve Developer Productivity

Rust Survey Revelations

Rust Is Safer But Do We Use It Safely

Is Rust Really Safe?

Oxide - A Simpler Formalized Rust

Rust Gets Async-Await

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.


Raspberry Pi - You Can Have 10 Zeros! Updated

The shortage of Pis has been a real problem. At the end of last year we were promised that the situation would be easing in the new year, but it didn't noticeably change. Now we have news that you can [ ... ]

Microsoft Announces Dev Box Portal

Microsoft has announced several improvements to the preview of Dev Box, a managed service that is due for release this summer.

More News





or email your comment to:




Last Updated ( Tuesday, 04 May 2021 )