4 ms·
>The Err and Ok could seem weird, traits could really be confusing. C++ allows similar error handling with std::optional (Some()/None in Rust) or std::variant
by constantcrying 3y ago
>The Err and Ok could seem weird, traits could really be confusing.
C++ allows similar error handling with std::optional (Some()/None in Rust) or std::variant (Err()/Ok() in Rust). C++ also has something similar to traits (with really unreadable syntax).
C++ just has a worse syntax for Error handling, since variants aren't enums. If you are using C++ I suggest you still make use of these concepts.
- wslh 3y agoI wasn't saying either C++ or Rust are better or worse, just saying that Rust is not C++ done well which I think it is a very exaggerated claim.
- constantcrying 3y agoAnd I pointed out that C++ includes somewhat worse versions of those concepts.
- wslh 3y agoAnd where do you think C++ is better than Rust?
- jandrewrogers 3y agoFor my use cases, modern C++ is clearly more powerful/expressive than Rust in a couple areas today: metaprogramming and software where object lifetimes/ownership are unknowable at compile-time. These have a large impact on development productivity and software quality, so I'd be reluctant to give them up. Rust has a bunch of other odd gaps, e.g. lack of proper thread-local support, but I can live with that.