13 ms·
In the future as C++ evolves (it had a hiatus of a decade or more where not much happened) it will be interesting to see how it will compare to Rust. C++ is p
by actionfromafar 4y ago
In the future as C++ evolves (it had a hiatus of a decade or more where not much happened) it will be interesting to see how it will compare to Rust.
C++ is performance first at any price. Hence UB.
Rust is also after performance, but will specify implementation details where C++ will defer to compiler writers.
- gmadsen 4y agoI don't think thats correct.. C++ has UB because of backwards compatibility, which has origins to design choices of C in the 70s. Its not like it is optimized for performance above all else, it had immediate needs to be close to metal, and that is the best they could do back then, there was not some "strongly typed" versus "performance" debate happening at the time. The creator of C++ would love for there to be safer abstractions, but has the baggage of the past to carry.
- pornel 4y agoModern C++ is still a safety-third design. std::optional is relatively new, and supports dereferencing, which when it’s empty is UB instead of an abort. There are no plans to add checks to any existing APIs, because “it didn’t have a branch before” is also considered a compatibility issue.
- gizmondo 4y ago> C++ is performance first at any price. Hence UB. I don't think this is entirely correct, C++ in some cases famously preferred ABI compatibility over maximum performance.
- vlovich123 4y agoC++ has no ABI defined. Did you mean API comparability? Would help to clarify some examples
- sirwhinesalot 4y agoWhile the C++ standard does not define any ABI, some implementations (namely GCC and clang) put a lot of effort into maintaining reasonable ABI compatibility. GCC has only changed ABI twice (afaik) and the second time the only thing that changed was std::string! Nowadays MSVC tries to maintain ABI compatibility too, so we should stop seeing a proliferation of those msvcrXXX dlls. Haiku uses C++ for its OS ABI so it relies quite heavily on the fact that ABI compatibility stays very consistent across compiler versions for example.
- pjmlp 4y agoSame applies to Rust, with the difference that there isn't a story for shipping binary libraries, that is why OSes like Haiku care about keeping the ABI consistent, those BeOS applications aren't going to be recompiled.
- bigbillheck 4y agohttps://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2028r0.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p20...
- vlovich123 4y agoInstead of breaking ABI compat for `unordered_map` why not define a new type given that it's so different? It can even be called the same thing and just exposed through a different namespace version (something that's been supported for a while). About the only thing real is intmax_t. The rest feel resolvable within a library without changing ABI / breaking back compat.
- mort96 4y agoThe committee won't change something if the change would break the ABI of one of the big implementations. It's not a formalised ABI stability promise, it's just a result of implementers having veto power and wanting to keep their implementation's ABI stable.
- stefan_ 4y agoAs anyone who has looked at disassembled C++ code can attest, "C++ is performance first at any price" aka "zero-cost abstraction" is mostly a pipe dream. Whatever sufficiently smart compiler was meant to make it happen has not materialized.
- bigbillheck 4y ago> (it had a hiatus of a decade or more where not much happened) C++11 is almost as old now as C++98 was when C++11 came out. It's evolved plenty.