July 22, 2024

Google Busts, Confirms Common Myths about Rust Programming

Google Busts, Confirms Common Myths about Rust Programming

Earlier this summer, Google did a retrospective on its use of the Rust programming language, delving into such issues as how long it takes for developers to become efficient with the language to compiler speed and the overall quality of Rust code.

In a blog post, two in-house Ph.D. eggheads, Lars Bergstrom, a Google director of engineering working on Android Platform Programming Languages, and Kathy Brennan, a low-level Operating Systems Sr. User Experience Researcher, looked into some of the key rumors about the use of Rust as well as pros and cons of using the relatively new language — which just reached version 1.0 as recently as 2015, versus the nearly 30-year-old Java workhorse that will see release 21 next month, for instance.

The post entitled “Rust fact vs. fiction: 5 Insights from Google’s Rust journey in 2022,” sheds light on what over 1,000 Google developers who have authored and committed Rust code as some part of their work in 2022 had to say, Bergstrom and Brennan explained, as Google has seen increased Rust adoption, particularly in its consumer applications and platforms.

Code Quality

The study confirmed a key “myth” or notion about Rust that it enables developers to deliver high-quality code.

“The respondents said that the quality of the Rust code is high — 77% of developers were satisfied with the quality of Rust code,” the post said. “In fact, when asked to compare whether they felt that Rust code was more correct than the code that they write in other languages, an overwhelming 85% of respondents are confident that their Rust code is correct.”

Moreover, that correct code also is easy to review, as more than half of respondents said that Rust code is incredibly easy to review.

“As an engineering manager, that result is in many ways at least as interesting to me as the code authoring results, since code reviewing is at least as large a part of the role of a professional software engineer as authoring,” Bergstrom noted in the post. “As both, we at Google and others have noted, developer satisfaction and productivity are correlated with both code quality and how long it takes to get a code review. If Rust is not only better for writing quality code, but also better for getting that code landed, that’s a pretty compelling set of reasons beyond even performance and memory safety for companies to be evaluating and considering adopting it.”

Hard to Learn?

Meanwhile, the study debunked the notion that Rust takes more than six months to learn.

Indeed, based on the Google study, more than two-thirds of respondents said they were confident in contributing to a Rust codebase within two months or less when learning Rust. Further, a third of respondents said they became as productive using Rust as other languages in two months or less. And within four months, that number increased to over 50%.

Compiler Speed

The Google study also confirmed the nagging notion that the Rust compiler is not as fast as people would like.

“Slow build speeds were by far the #1 reported challenge that developers have when using Rust, with only a little more than 40% of respondents finding the speed acceptable,” the post reads.

And there is a community-wide effort to improve and track rustc performance.

“This is supported by both volunteers and several companies (including Google), and we’re delighted to see key developers working in this space but clearly continuing and potentially growing additional support here would be beneficial,” the post reads.

Error Messages

Another “myth” that Google confirmed is that Rust has “amazing” compiler error messages.

“Rust is commonly regarded as having some of the most helpful error messages in the compiler space, and that held up in this survey as well,” the post said.
For instance, only 9% of respondents said they are not satisfied with the quality of diagnostic and debugging information in Rust.

“People are amazed by the compiler messages. At first, this is a surprise — people are used to ignoring large compiler errors, but after getting used to it, people love it,” Google said.

The Biggest Challenges

Meanwhile, the Google study also debunked a fifth myth — that unsafe code and interop are always the biggest challenges.

For example, the top three challenging areas of Rust for current Google developers were:

Writing unsafe code and handling C/C++ interop were cited as something Google developers had encountered but were not top challenges.

Yet, “These three other areas are places where the Rust Language Design Team has been investing in flattening the learning curve overall as well as continued evolution, and our internal survey results strongly agree with these as areas of investment,” the post reads.

Google plans to continue to keep an eye on its adoption of Rust and its impact on developers and code. Updates to this study will come in the form of broader surveys featuring more than 1,000 developers.

Group Created with Sketch.