| Exactly, show don't tell. And when I point to the fact that the Rust codebase itself has a lot of "unsafe" places I get the explanation "yes, but it's an old code and we haven't had the time to rewrite it to use the newer features that would allow more safe code." Think about it: the people who design Rust don't have the time to rewrite their own Rust code to be safe. When there's no time to rewrite the code of Rust to be demonstrably safe, why should any other project have more time than that, where the programmers know Rust much less or not at all? Maintaining the successful project is hard and takes a lot of time, even without switching to something new. Second point: look at the Benchmark game, a fast Rust code example also typically has an "unsafe" code. So it's still not even demonstrated that "you can have it both fast and safe" holds for these examples. Fast as in "as fast as C" and "safe" as in "provably safer than C." Finally, I believe that the language should simply implement a language-level no-cost check for integer overflow, as the machine languages already have, and not complain that there aren't some special mechanisms in CPUs to do it differently. It's your language's failure if you can't use what already exists. The CPUs already can do it, the high level languages don't provide the high-level access to it. Which doesn't matter for C which is "unsafe" by definition (and where it's natural to call some asm when needed) but it should for Rust which goal is to produce a more provably "safe" code. Writing unsafe Rust instead of unsafe C is not giving you any real advantage for the existing projects, as long as the state is as it is. Also, look how Rust uses TLS. Is safely rewriting a crypto library which is useful in real project still a too big task to be taken? I like the perspectives of what Rust could bring. But I'd like to see a real life case of its success too. |
Your argument hinges pretty heavily on this. It's incorrect. The reality is that unsafe code in rust is not like unsafe code in C. First, it's bounded to a module. Second, you can grep for it (huge). Third, you still have less UB in unsafe rust than in C.
I've never written code in rust that required unsafe, after many thousands of lines.
> Is safely rewriting a crypto library which is useful in real project still a too big task to be taken?
https://github.com/ctz/rustls
?????????????
> But I'd like to see a real life case of its success too.
Ripgrep is a nice one to point to. There's redox too. Tons of rust code out there.