What I’d like from Rust 2021

I’ve been a user of Rust now for 2 years. It was something of a revelation – I was amazed at how well thought out the core of the language is – many classic C++ gotchas and kludges (null pointers, double free, use after free, slicing, diamond inheritance) have been completely designed out. In that time the language and compiler has evolved rapidly, with const functions, async await, and (hopefully by the end of the year) const generics. I’m lucky enough to have been working with Rust full time for most of the last 2 years, building an exchange for a fintech startup. As such performance is a key goal, and the reason we picked Rust over Java or Go. We are very happy with the choice, but there are always things we can improve on. So with that in mind. Here are my themes and priorities for what I’d like from Rust in 2021.

1. Expressive Performance

Rust is already both expressive and performant, but has some way to go to match C++ yet. C++ generics are still the gold standard to beat, with specialization, const generics and higher kinded (duck) types. From the perspective of building high performance ultra low latency software, being able to express things at compile time is critical for controlling performance. Therefore I’d really like to see const generics (https://github.com/rust-lang/rust/issues/44580), specialization (https://github.com/rust-lang/rust/issues/31844), and GATs (https://github.com/rust-lang/rust/issues/44265) to be pushed forward in 2021.

2. Rust and Rust Analyser, together forever <3

Rust analyser is awesome, in particular the pace of development is a sight to behold. But it’s are still not quite aligned with Rust. I’d love to see both the rust analyser team and rustc team push forward on the work (like chalk integration in rustc) that would help bring rust-analyser towards full parity with rustc.

I often still have issues with rust analyser not working on my large workspace, whereas when I open up a simple project, it’s flawless. I have yet to work out exactly what causes this, but it feels like it needs some work on large workspaces.

3. Scaling Cargo

I love Cargo – partly because it’s not (C)Make, but mostly because it makes building rust code so extremely simple. However it has some issues as codebases scale up and get more complex. Larger codebases can use multiple languages, sometimes more than one toolchain and pre or post build processing. Not every tool was designed to work seamlessly with rust and cargo, not should we expect it to.

  • Post build scripting: This would be incredibly helpful for projects that require creating packages, or generating manifests etc. There is an issue tracking this, which appears to be in RFC hell: https://github.com/rust-lang/cargo/issues/545.
  • Workspaces: Workspaces currently have weird quirks at the moment – for example a project’s dependencies can have different features activated depending on whether it is compiled as part of the whole workspace or with -p! (https://github.com/rust-lang/cargo/issues/4463)
  • Cargo config: Cargo config is done using hidden files, which seem to be relative to the working folder you run Cargo from, not relative to the project they apply to. This in particular cause some weird subtle bugs that took us a while to work around. It feels like a lot of this ought to be in the Cargo.toml manifest instead. (https://github.com/rust-lang/cargo/issues/8244)

4. Encouraging contributions on work for the roadmap

Rust has a stellar community full of bright developers, who are keen to contribute. I’d like to contribute, but I don’t know where to begin. Particularly hot topic issues, like GAT or specialization – the issues are huge, and I have no idea who is currently working on them or what state they are in, or even if I have the knowledge to help. If we are to get these big features out of RFC hell and into the stable compiler, it feels important that they are brought to the fore more publically than where they are now. How we do this I’m not sure, possibly a section of the main website which lists roadmap progress/calls for assistance. These things are hard to find currently, even when you know what you are looking for :).

5. Compiler speed is not a priority

I’m sure many people will disagree here. I think that this is currently less critical than the outstanding feature work. Whilst we can all do with more compilation speed, I’d rather have an amazing rust analyser experience and a super expressive type system. These things together would have a much bigger impact on my productivity than a faster compiler.

Leave a Reply

Your email address will not be published. Required fields are marked *