5 ms·
> every single part of it is deeply flawed, and the best solution is to avoid using it completely You can sadly say the same for a large part of C++ standard f
by Asooka 6y ago
> every single part of it is deeply flawed, and the best solution is to avoid using it completely
You can sadly say the same for a large part of C++ standard features. At least the core language is mostly sound, simple intuitive and performant, so having to file off some edges is not that big of a problem.
- MaxBarraclough 6y ago> the core language is mostly sound, simple intuitive and performant I wouldn't say so. Even object initialization is atrociously complex in C++. https://stackoverflow.com/a/620402/ https://stackoverflow.com/a/620402/ https://stackoverflow.com/a/54350350/ https://stackoverflow.com/a/54350350/
- quietbritishjim 6y agoOr move semantics including rvalue references. In retrospect, objects should have been moved by default (and destructors for moved-from objects not called), like Rust. Then copying can just be an explicit normal method (that returns its result by moving it!).
- Veedrac 6y ago> and destructors for moved-from objects not called This doesn't work entirely cleanly in cases the compiler can't track liveness, which is more of an issue for C++ than Rust, since you want to be able to move out of pointers. A simple solution is to replace move operators with an `invalidate` function the compiler calls after doing a shallow move, that sets the old value to a moved-from state. Copy constructors (as opposed to copy assignment operators) are already a fine way to copy a value, there's no real need to change that.
- deleted 6y ago[deleted]
- Asooka 6y agoObject initialisation complexity is a consequence of the design goals of C++. It's unavoidable complexity, but it's not surprising once you know about it, and it is required for consistency.
- leni536 6y agoIt's also a consequence of some unfortunate mistakes, like uniform initialization being screwed up by std::initializer_list.
- MaxBarraclough 6y ago> it's not surprising once you know about it I disagree. My first link shows subtle but important differences across versions of C++, and it is surprising. It's a foot-gun at the heart of the language. I agree with the author's comment: This is one of the dusty corners of C++ that can drive you crazy.
- tsimionescu 6y agoC++ is pretty performant, that much is true. But no aspect of C++ is simple, almost all C++ features have complex interactions with almost all other C++ features (I can back this up with examples, if you'd like). And there's always the specter of UB making your benign program have no semantics. There is no other language as complex as C++. Still, for its relatively larhe niche, there is nothing that beats well-written C++. Thankfully, that niche has been ever-shrinking, though very slowly. Perhaps Rust will stake a claim to another part of C++'s niche, like Java/C# did so successfully before.