4 ms·
The most common example is aliasing. Since the rust type system promises that you won't have two mutable aliases to the same data, even data coming from an unkn
by TheDong 4y ago
The most common example is aliasing. Since the rust type system promises that you won't have two mutable aliases to the same data, even data coming from an unknown caller, the compiler can in theory make optimizations that aren't possible in other languages that permit multiple mutable aliases.
Especially for values that cross the boundaries of compilation units, the compiler in another language cannot possible have enough information to know if aliasing could occur.
- howinteresting 4y agoI think we haven't even come close to harnessing the full benefits of (1) mutable references can't be aliased, and (2) referential transparency: data behind an immutable pointer never changing no matter how many aliases to it there are. (The exception being UnsafeCell, of course, which can easily be detected.) Exciting times ahead for Rust performance!
- jjtheblunt 4y agoalias analysis in Rust is great, but friends worked on it in optimizing compilers in Urbana-Champaign in the early 1990s, so it's possible Rust is its most widespread rollout.
- jamincan 4y agoIt's possible to specify no alias in C with the `restrict` keyword, but it isn't a widely used feature. With Rust, a whole bunch of bugs related to it were found and fixed in LLVM, so I think you're correct that it is the most widespread rollout.