Estimate project
← All posts

How Rust Became Part of My Story: from Clippy lints to This Week in Rust

Here comes another interview from our Rust interview series! Our guest contributes to and mentors in Rust, edits This Week in Rust and maintains Clippy.

7 min read
Rust

Another one bites the… Rust 😉 Year after year, Stack Overflow Developer surveys have named Rust the most loved programming language. Let’s find out why from the perspective of Rust community leaders.

Here comes another interview from our Rust interview series! Our guest contributes to and mentors in Rust, edits This Week in Rust and maintains Clippy.

How did you first get introduced to Rust, and what were your initial thoughts about it?

Being a fan of programming languages, I keep an eye on what is new. Before Rust, I picked up a new language every year or two. So in 2014, I took a look at how it was being developed and appreciated how open the process was. Still, I did not write my first code until 2015 (just before 1.0): the eq_op lint, which clippy still includes today.

Can you share a moment when you realized, “Wow, Rust is amazing”? What features or capabilities of Rust made you feel that way?

Honestly, there are more than I can count. The first one was finishing a lint in a language I had been learning for only a few hours. It compiled, and it worked right away. Another was seeing the rayon prototypes and comparing them to Java streams (which achieve the same thing with more overhead and more limitations). And reading the compiler’s error messages always gives me a thrill – they are excellent. Not to mention how helpful the community is.

How has Rust influenced the way you approach solving programming challenges?

Building an API that is hard to misuse is definitely easier in Rust than in other languages, because the borrow checker can enforce object lifetimes. And enums are the greatest thing since sliced bread.

If you could add a new feature to Rust, what would it be, and how do you think it would benefit developers?

I have contributed several features to Rust, starting with the #[deprecated] annotation, my first RFC and implementation to be accepted. I also wrote the code that lets doctests simply return a Result without needing a main()-function. My most recent contribution was the Option::as_slice method. Something I have not done yet but would like to see is write-only references, which would turn the uninit/assumed-init distinction of MaybeUninit into part of the type state, giving us a safe way of handling uninitialized data.

What’s your favorite programming meme?

There is a game called Rust, so some people mix up the game and the language – why not add to the confusion?

What tools and libraries do you rely on when working as a software developer?

Naturally, rustc, cargo and rustup as the compiler, build system and updater.

The editor/IDE I prefer is helix, and git handles my version control.

There are so many excellent libraries that picking a handful to highlight is tough, but regex, serde, tokio, sqlx, fst, roaring, rayon, clap, itertools, parking_lot, criterion, proptest, and insta definitely deserve a mention.

Tell us about a time when Rust made a significant difference in a real-world project

Up until the pandemic, I served as VP of Engineering at an AI company, where our in-house ML expert had written a Python script for cleaning some data (a few GBs of it). He had also added an estimation function, which showed the script would need about a week to finish. We did not have a week, so I spent under an hour porting the script to Rust. The Rust version completed in about ten minutes.

How has the Rust community shaped your programming journey? Are there any standout interactions or stories of support you’d like to share?

That is a tough one, since I have so many stories to tell.

  • Rust is the first language whose development I have been able to contribute to. I would never have expected that with any other language (least of all a low-level one like, say, C or C++). Its open development process is truly wonderful.
  • I once tweeted that I wished rust-analyzer let me click on a test to run it, and by the following day it had been implemented.
  • The Rust community has treated me very kindly, so I chose to pay it forward by becoming a Rust Mentor as well as a This Week in Rust editor.

Did you experience any funny or embarrassing moments while learning Rust?

Want to know what is funny? I get plenty of clippy warnings – from lints I wrote myself. That is fine, though; it means I do not have to remember everything.

What advice would you give to someone just starting out with Rust?

Do not aim for perfection on your first try. Get something that compiles (since, as we all know, it will usually work as well). You can always polish it later. Also, try to learn how to make good use of the data types provided, as well as your own structs and enums. Lastly, do not stress too much about lifetimes and ownership until error messages show up, because the compiler has your back regardless.

How have you seen Rust evolve over the years, particularly in your area of work?

Since I started with Rust by writing lints, I spent most of my time on nightly. That is how I witnessed the early experiments that later turned into derives, proc macros and async/await. The last of these in particular is now much more complete than it was at the start.

What do you predict for the future of Rust over the next decade?

Rust will keep evolving, though probably more slowly, as the existing implementation hardens and becomes more difficult to change. The community will surely keep growing (considering the White House’s new interest in memory safety, along with that of various consumer advocacy groups). A few new features we have been waiting on for years will at last be stabilized (I am hoping for the never type, some form of specialization, proc-macro-expand and the new range type).

Is Rust only for systems programming, or do you see it as a valuable technology in other areas as well?

Rust is the only all level language I am aware of. For a long time, we tried to find such a language by working our way down from the high level (Java, C#, Go, etc.). Those, however, always need a runtime (even though Go’s runtime is quite lean, and GraalVM can do surprising things with Java byte code), which always rules out full control over memory layout and therefore caps how low you can go. Rust, by contrast, began at the low level and grew abstractions on top whose quality rivals anything found in those other high level languages. This is fantastic, because I no longer need to bind a scripting language for my high-level code. For instance, I can write a low-level parser using all the SIMD tricks I want to squeeze out every last bit of performance, yet put a simple iterator interface on top that gets all the perks of that trait for free. On top of that, I can then write simple loops or filter, map, fold, etc. combinations just as I would in a functional language. And all of it compiles down to something that is (to quote the meme) blazingly fast while remaining easy enough to maintain.

In February, Lars Bergstrom of Google presented a study showing that Rust and Go engineers developed roughly twice as fast as their C++ counterparts, and that Rust engineers were over 80% confident their code behaves as intended. I am not entirely sure how this stacks up against other languages in use out there, but my gut feeling is that Rust can pay off nearly everywhere. In a blog post back in 2018, I argued that Rust front-loads a great deal of complexity because it will not let you cut corners. So although you should expect to be slowed down while first writing the code (how much depends on several factors, your Rust proficiency among them), you get that time back with interest when debugging, maintaining, and refactoring.

Lastly, because thread-safety is built in from the very beginning, Rust has an edge in any application that aims to use the available hardware (which, unless you are into retrocomputing, will be multicore). Most non-functional programming languages (e.g., Java, Python, etc.) cannot match that.