the core of rust

58 points by calvin


matklad

Within Rust, too, there is a much smaller and cleaner language struggling to get out: one with a clear vision, goals, focus.

On the meta level, I sort feel that Rust does have a rather clear vision, and that is being industrial language, which means accepting unfavorable tradeoffs in the interest of letting the users ship real-world software. Rust is an increasingly practical language. This is a different vision from what one might originally expected it to be — a safe low-level language. I wonder how Rust would’ve looked in an alternative universe, where C# wasn’t for the most of its life a window-only language, but rather started with .NET core and with features like spans.

On the language design level, “is there a smaller Rust, that’s still Rust?” is an interesting question to ponder! I feel like, in general, no. You need monomorphisation, traits, unboxed closures, and lifetimes to make zero-cost memory safe abstraction work. This is the core of Rust:

https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.map

That being said, it does feel like there’s a bit of gratuitous complexity, which could be removed without much harm. Name resolution can be massively simplified, I don’t think there’s a fundamental need to have 3 ½ namespaces, distinguish between . and ::, and allow for non-trivial mapping between modules and files. While there’s a clear need for some sort of the macros to make derive work, I feel this can be done simpler. Macros that introduce arbitrary custom syntax feel like they are not that necessary. Maybe the syntax can be simplified somewhat (<>, .0), but that’s minor.

And that’s … all I think that’s clearly simplify-able, language-wise? It’s not clear to me how we could’ve made async simpler (one option would be to bless stackfull coroutines as a library, and let sans-io people write state machines manually, but that’s not a clear improvement). const-fn I think could be simpler, but that’s not yet in the language even, so doesn’t count :P