5 ms·
That would also be a bit confusing because it can be interpreted (incorrectly) as that all languages with garbage collectors offers all the safety guarantees of
by alkonaut 7y ago
That would also be a bit confusing because it can be interpreted (incorrectly) as that all languages with garbage collectors offers all the safety guarantees of Rust.
A trivial counterexample is the protection against data races.
- CJefferson 7y agoYes, as I do more rust, I love the fact I can safely parallelise more than I love the memory protection. Before Rust, I was close to saying that thread-based parallelization was almost impossible to do safely, and was moving to only doing process-level parallelization.
- littlestymaar 7y agoThis was actually the reason why Graydon Hoare created Rust BTW. He wasn't looking for a way to get rid of garbage collection or an alternative to C++ (those two characteristics came later from Mozilla, the first versions of Rust had a GC and a heavy runtime with green threads and all), but he wanted a language that helped using all cores on the machine without the traditional issues of shared-memory multithreading.
- jfkebwjsbx 7y agoFalse, because Rust does not offer protection against race conditions. Do not confuse data races (a subset of race conditions that many languages solve) with race conditions (a way harder problem that there is no general solution to).
- dgb23 7y agoAgain, that is provided in higher level languages by abstractions over mutable state, such as STM (example: Clojure's Refs and Atoms [0]). And/or by making immutability the default. Neither that, memory safety, nor forcing you to deal with optionality is unique to Rust. The big difference is that Rust manages to do these things while also having similar performance characteristics as C/C++. The trade-off is that the programmer has to explicitly deal with these issues. I personally haven't yet seen a safety language feature of Rust that is not somehow available in other languages with similar claims. I would appreciate learning otherwise if I'm missing something. I think the only feature that would push Rust to being at the forefront would be "const generics" [1] or true dependent types down the line. [0] https://en.wikipedia.org/wiki/Software_transactional_memory https://en.wikipedia.org/wiki/Software_transactional_memory [1] https://github.com/rust-lang/rust/issues/44580 https://github.com/rust-lang/rust/issues/44580
- jfkebwjsbx 7y agoVery well said. Rust is the perfect option for projects that: 1) are exposed to untrusted data 2) and, at the same time, their performance is critical If one of those isn’t true, there are better options. If they are both true though, Rust is pretty much unique.
- nicoburns 7y agoWhat would you use where correctness the top priority? Haskell? For the best thing about Rust isn't the performance (although that's great). It's just how reliable my Rust projects have been in production. If you wanted this level of reliability from another language, you'd have to write tests to cover all the possible failure cases. Which is much more time consuming than having the compiler point out all the possible failure points for you.
- jfkebwjsbx 7y agoIf correctness is the top priority, then formal verification methods and/or SPARK and/or specialized subsets of C with the tooling that comes with them for safety projects. Rust and Haskell and standard C and C++ are all non-starters.