Rust 2020 🦀
Every year I think of writing a “Rust 20xx”1 post, and I never do, but this year I've decided to power through the procrastination, I'm also on a 5 hour flight with no Wi-Fi, so this will at least provide me with some form of entertainment!
Since I'm blessed enough to work full-time using Rust2 I end up having two separate sets of goals for Rust, one from the point of view of Standard Cognition (Sc) as a company that is committed to Rust, and another as someone who likes to work on projects in Rust in his free time. I'll separate both, and try to not jumble my wishes for Standard and my personal ones.
Standard Cognition & Rust in 2020
One of our main annoyances at Sc is the fact that we are still on the nightly compiler, mostly due to a number of features that we couldn't build our product without, but that still haven't seen their way through to stabilization. Namely, these are:
I'm fairly sure a couple of these have only recently been stabilized, but we
only bump the compiler once in a blue moon since it's usually a bit of a
chore. Most notably, the
never_type was just stabilized!
There are some other features that we don't use, but only because the path for them to be stabilized is so unclear and we didn't want to further commit to using unstable features. The big ones here, where stabilization would be a revolution in our codebase are const generics and GATs. My understanding is that for the former we would ideally achieve lazy normalization inside the compiler, and that there's still quite a bit of work ahead of us for that. For GATs I'm not quite sure which yaks will need to be shaven.
Another thing we'd like to see at Sc is a number of improvements to Cargo, some things that come to mind are:
- We'd like for it to not have network access, and possibly only limited filesystem access. Right now the build script has unlimited power, which is really no good.
- Better dependency handling
- There are a number of annoyances in Cargo relating to
dependencies. The primary one being that if a crate exposes both a
binary and a library (c.f.
bindgen, etc) but you only use the library portion you must still download and build all the binary-only dependencies. Another issue is that
build-dependenciesshare the same resolution graph with
dependencieswhich causes issues in settings where the target doesn't support a build dependency even though only the host needs it (for building.)
- There are a number of annoyances in Cargo relating to dependencies. The primary one being that if a crate exposes both a binary and a library (c.f.
- Better integration with other build systems
- Cargo is pretty great as a standalone build tool for Rust, but it's pretty bad at integrating with anything else. At Sc we use Nix everywhere, and the intgration with Rust has been painful, though there are promising projects like crate2nix.
The last big thing we're excited about is async/await, here are some of the things we're still missing from it:
- Ideally we'd model a lot of our workloads with streams, so we'd love to see them stabilized and well-supported.
- Stable ecosystem
- It feels like Tokio has been around since forever without reaching 1.0 status, we'd like to see more proactiveness around stabilization; async-std has been a positive force in this space.
- On a separate note, the Rust ecosystem as a whole has started abusing semver in weird ways, such as versioning crates to the liking of `0.1.0alpha7 as opposed to just bumping the revision. Let's bump revisions in the 0.x range quickly and aim for stabilization; having to tag a 2.0 some day isn't the end of the world.
- Clear performance metrics
- As the ecosystem becomes increasingly diverse it'll become necessary for there to be a “unified measuring stick” so that performance can be reasonably compared.
As a final note on Sc, I think it's easy for us who are heavily invested and deeply embedded into Rust to miss the forest for the trees and think that the lack of this or that feature, or that the existence of one or another wart in the ecosystem is a much bigger deal than it really is. Asking my coworkers who learned Rust on the job and transitioned from C++ and Java the feedback is overwhelmingly positive, even about the ‘wartiest’ parts of the ecosystem. I think Rust has achieved a lot more than we give ourselves credit for.
Bernardo & Rust in 2020
While most of my desires for Rust align with Sc's there are a few things that are strictly personal wishes, namely:
- Rust 2021
- I think we should have an edition in 2021, and if the 2018 edition taught us anything it's that we should take more time in the edition process, I think two years instead of one will be a huge win.
- Better embedded support
- It's a bit silly that we still need to use cargo-xbuild (fka. xargo) it's about time Cargo has first-class support for these use-cases.
- Stable ABI
- Lazy normalization
- Simple ways to unify CLI options and config
- Right now it's simple to create a CLI app with rust using structopt, and it's also trivial to define and source a TOML config file, but combining both is not nearly as easy as it could be.
- Better IDE support
- RLS is alright, but still has ways to go, and the 2.0 efforts are promising, but we have to see these things through.
- Parsing Rust is not easy, the vim syntax highlighter struggles with large Rust files.
- Further work on unsafe guidelines.
If you're reading this after 2099, sorry for the inconsistency.
We're hiring! You can reach me at firstname.lastname@example.org