3 ms·
You can have options and results in C++ if you like (I sometimes use custom result types, and I certainly don't use exceptions), but there's no language-level s
by keldaris 7y ago
You can have options and results in C++ if you like (I sometimes use custom result types, and I certainly don't use exceptions), but there's no language-level support for them and that's valuable, I agree. Not sure I understand the second point (I don't have to create uninitialized variables in C++, though I may sometimes want to). As for undefined behavior, I don't personally view that as an issue at all for the most part. I write code for a specific set of compilers running on a specific set of hardware, not an abstract standard. The behavior is what the compiler does (or rather, what I cause it to do) and there's nothing undefined or arbitrary about that.
Anyway, I agree that some aspects of Rust unrelated to memory safety are good for correctness. Unfortunately, I can't pick languages in a vacuum, so I have to weigh that against things like GPGPU support (first rate vs. non-existent), tooling quality (particularly profilers), library support (Eigen alone is worth quite a lot) and other factors. If I could ignore all of those real world issues and just choose the better language, I don't know if I would choose Rust, but it would certainly have a decent shot.
- lmm 7y ago> You can have options and results in C++ if you like (I sometimes use custom result types, and I certainly don't use exceptions) It's not really practical because C++ has no true sum types. You can emulate them with a Java-style visitor pattern but that carries an immense code overhead.
- lenkite 7y agoYou have std::variant and std::visit. https://www.bfilipek.com/2018/09/visit-variants.html https://www.bfilipek.com/2018/09/visit-variants.html Or you can use a library: https://github.com/mpark/patterns https://github.com/mpark/patterns
- lmm 7y ago> You have std::variant and std::visit. https://www.bfilipek.com/2018/09/visit-variants.html https://www.bfilipek.com/2018/09/visit-variants.html Which isn't a true sum type because it doesn't nest properly. > Or you can use a library: https://github.com/mpark/patterns https://github.com/mpark/patterns Interesting; proper pattern-matching is nice, but the lack of type safety is still a major issue.