4 ms·
Rust is absolutely a safe language, and in more ways than just memory safety. The only way to get unsafe code in rust is to opt in to unsafety with a keyword th
by jjnoakes 4y ago
Rust is absolutely a safe language, and in more ways than just memory safety. The only way to get unsafe code in rust is to opt in to unsafety with a keyword that can easily be checked for, so that you can decide for yourself to enforce that no code in your project uses it.
And unless you are writing a few specific types of code, using unsafe usually isn't ever necessary at all.
The complexity is also very much not an issue in practice. If you rub up against complexity in C++, you might not even know it. UB could be silently ruining things. If you rub up against complexity in rust, you were either just saved from yourself, or you are hitting part of the language that is probably undergoing improvement. But you never have to worry about complexity silently making things worse.
- mcronce 4y agoIt's also super easy to enforce at the crate level with #![forbid(unsafe_code)] if you feel so inclined - no manual checks necessary
- coliveira 4y ago> complexity is also very much not an issue in practice. In practice, people find otherwise. It takes a steep learning curve to use Rust compared to Java, for example.
- jjnoakes 4y agoWe're comparing rust to c++ in this thread. There are simpler languages than both out there, sure, but that's not really relevant here.
- coliveira 4y agoNo, the comparison is against languages considered "safe" like Java, Go, Swift, and Rubi.
- jjnoakes 4y ago"Moreover, Rust is extremely complex, similar or worse than C++"
- coliveira 4y agoThat's my point, if Rust is as complex as C++, it is not a good choice compared to the other languages. In fact, many people still avoid C++ and use C exactly for this same issue, C++ is too complex to use. These people who use C will justifiably have the same argument against Rust, it is too complex, and migrate when needed to something else like Go.
- jjnoakes 4y agoIf a less complex language meets your requirements, by all means use it. But I still have no idea how that is relevant here. C doesn't give you safety and less complex languages don't give you performance and control. That's why comparing rust to c++ is useful. But the way I think the higher complexity of rust over c is also not a big deal in practice, for much the same reason as I gave for rust vs c++. But that is also irrelevant here.