Hacker News new | ask | show | jobs
by nercury 957 days ago
I would avoid saying that it's "Rust" that "gives guarantees". It paints Rust as this magical thing that will solve anything. My preferred explanation is that Rust provides better tools to build wrappers that can't be misused. The idea is to solve hard problem once, and reap the benefits many times. But it all depends on wrapper author. In that regard, it is perfectly possible to write horrible Rust code.
1 comments

> I would avoid saying that it's "Rust" that "gives guarantees".

Why would you avoid saying that? Rust does give guarantees: about memory safety and concurrency primarily, but also regarding the lack of undefined behavior.

> It paints Rust as this magical thing that will solve anything.

It does not, the above are not magical they are just challenging problems (although at some point they may have been deemed impossible problems and hence magical, I don't know)

> My preferred explanation is that Rust provides better tools to build wrappers that can't be misused.

"wrappers that can't be misused" sounds a LOT like it "gives guarantees".

The biggest wrapper that gives guarantees is the standard library, and usually, when people say that Rust does not do something, they have standard library in mind. For example, standard library made the choice to hide panics in out-of-memory situations. That does not mean you can't write your own version of relevant structures to gain different guarantees. I like to highlight the actual strengths of Rust (as a tool) instead of particular implementation details, especially when we are talking about situation (kernel) where Rust is used without its standard library.
Rust the language gives these guarantees without the use of the unsafe keyword:

* you will not be able to compile undefined behavior

* you will not be able to create a data race

* a shared reference is read-only

* you cannot write past the end of an array

There are others, but those are pretty big ones that both guarantees and part of the language itself, independent of stdlib.