5 ms·
>Rust seems to be a very complex language. Is all that complexity essential to providing memory safety without GC? The language features specific to memory saf
by ivanbakel 6y ago
>Rust seems to be a very complex language. Is all that complexity essential to providing memory safety without GC?
The language features specific to memory safety i.e. the borrow checker, are essentially irreducible. It is also Rust's biggest piece of complexity, and the one that is hardest to learn. There is no simpler language inside Rust that has the same safety guarantees, unless you strip out other useful features (traits, async, etc.).
- pansa2 6y ago> There is no simpler language inside Rust that has the same safety guarantees, unless you strip out other useful features (traits, async, etc.). This sounds like “there is no simpler language inside C++, unless you strip out useful features (classes, templates, etc.)”. Yet C exists. So there could be a simpler language with Rust’s safety guarantees if you were willing to strip out traits, async etc?
- deleted 6y ago[deleted]
- ivanbakel 6y ago>So there could be a simpler language with Rust’s safety guarantees if you were willing to strip out traits, async etc? Well yes, there exists a hypothetical C + borrow-checker language. But that language wouldn't really be significantly simpler, because the borrow-checker is the largest contributor to Rust's complexity. The only things you would have taken away are the more well-understood features, as they already occur in other languages. The C/C++ comparison doesn't really work, because there is (to my knowledge) no single C++ feature which makes up the majority of its complexity over C. You could strip out independent features of C++ one at a time to return to a simpler language. Rust doesn't have the same property.
- dgellow 6y ago> there is (to my knowledge) no single C++ feature which makes up the majority of its complexity over C Maybe template programming?
- afavour 6y ago> There is no simpler language inside Rust that has the same safety guarantees I’d argue there is: there’s reference counting. Rather than using references and fussing with lifetimes you could sprinkle Rc<> wherever it’s necessary. You’d take a performance hit but the code would be simpler to write.
- cdcarter 6y agoIndeed, in fact, Swift often feels like Rust with automatic Rc<> for classes and Cow<> everywhere else.