5 ms·
As someone who's been doing C++ for a close to few decades I's challenge you on that. In C++ you need to understand: Exceptions(and the runtime/memory costs th
by vvanders 9y ago
As someone who's been doing C++ for a close to few decades I's challenge you on that. In C++ you need to understand:
Exceptions(and the runtime/memory costs they incur by pulling in RTTI)
ERRNO(on relevant *nix platforms)
Lifetimes tied to objects when things fail(this is a big one)
Plus any library-specific hackery(I've seen raw strings as errors before)
In contrast I've been writing Rust for ~1.5 years now and each library I've used is consistent and follows common patterns. Much like a lot of people don't grok functional until they understand the common patterns, so it is with Rust too.
- ahoka 9y agoExceptions don't need RTTI and have only runtime cost when thrown.
- cornstalks 9y agoExceptions actually can need RTTI, though not necessarily all of the RTTI that things like <typeinfo> provide. For some details, see the -fno-rtti flag for GCC, for which the documentation says[1]: Disable generation of information about every class with virtual functions for use by the C++ runtime type identification features (`dynamic_cast' and `typeid'). [...] Note that exception handling uses the same information, but it will generate it as needed. [1]: https://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/C_002b_002b-Dialect-Options.html https://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/C_002b_002b-Dia...
- pjmlp 9y agoThat is a compiler specific implementation, the ANSI C++ standard doesn't require it.
- vvanders 9y agoThat's great and all but when every modern compiler does implement it that way it's not something you can ignore. Show me a compiler that's used in production which handles multi-inheritance exceptions without allocating extra data and I'll be happy to eat my words :).
- pjmlp 9y agoSadly I cannot pay for all commercial compilers out of my own pocket. :)
- int_19h 9y agoThe ANSI C++ standard requires exceptions in the first place. The moment we start talking about disabling them, we're not talking about standard C++ anymore.
- pjmlp 9y agoWhich is why people cannot just state "In C++ the thing X happens" without regarding what the standard says, instead of what the installed compiler does. Language != Implementation. If the language would be "In GCC the thing X happens when ...", then ok.
- pcwalton 9y ago> Exceptions don't need RTTI and have only runtime cost when thrown. No, they add extra control flow edges, which inhibit optimizations, affecting runtime performance. This is a lot of the reason why unwinding is optional in Rust.