I have no particular opinion on contracts per se, but I do think that the C++ committee is procrastinating by focusing on niche features like contracts instead of dealing with the urgent issues (namely packaging and memory safety) where C++ is losing to Rust.
The rejection was a moment for them to reevaluate their priorities but it doesn't seem that they've gotten the message.
I sincerely hope that they keep procrastinating on packaging forever. Packaging is not a language concern. Its an ecosystem concern. Language packacke managers that are a giant pain for the rest of the ecosystem.
Losing to Rust is an interesting take. I never quite envisaged it this way.
If someone is considering writing in Rust, I doubt you will convince them that C++ is better instead. It's as if you're trying to tell someone going to the moon that Mars is the better choice.
Why should C++ "win" over Rust?
C++ already has the tools needed for memory safety, but it will never like Rust without serious compromises. Remember, C++ is C with extra features (except for a few minor details), C is not memory safe and will never be, so, for C++ to become memory safe, it has to depart from C, which to me is completely missing the point of C++. To me, the point of C++ is: "I want to write C, but I also want feature X", where is can be templates, classes, smart pointers, namespaces, etc... I don't have to use them all at once. For instance, if the only thing that interests me are templates, I just write my C code with raw pointers and all that, have my templates and compile it with a C++ compiler.
As for packages, there are already packages managers for C++, such as Conan. Unlike Rust, C++ is just a language, Rust is a trademarked brand, with a foundation that manages a whole ecosystem with the language itself but also a packet manager, build system, repository, community, etc... Different scope. For standardizing packaging, one would need a different committee, which may or may not align with the C++ revisions.
As for the "niche features", it is again the idea that C++ is C with extra features. Some people need contracts, give them contracts, others can simply ignore them. It is just another tool in the toolbox. Unlike Rust-like memory safety, it won't affect those who don't need it.
If you want Rust, use Rust, don't make C++ be Rust. Or maybe try some of the alternatives like Carbon.
If I understand contracts right, as in, that they're a basic form of dependent typing, I think that offers a form of safety in its own right.
As a fan of functional programming, I love this as a language feature. I also appreciate that it's profoundly opt-in, and I agree that package management and memory safety are more pressing.
I'm curious, as a C++ outsider: what memory safety features are currently being discussed that look most promising? How many would retroactively apply to existing code bases if compiled against an appropriately recent `--std` setting?
"C++ is losing to Rust."
This is a really weird way of stating this.
It's like saying "hammer is losing to a screw driver". These are tools with different requirements spaces.
But in general agree it feels more academic than industrial.
I don't get how this is 'urgent'. Frankly, as a C++ dev of ~7 years, it's very rare that memory safety is the part causing me issues or slowing me down.
I think the Common Package Specification goes a long way to fix packaging with C++ after trying it
They need a big ABI or possibly even API break to clean up. It's common enough to specify standards on the compiler command line now, and i.e. Microsoft's runtimes have handled multi-versioning for a long time.
Rust still needs to be fully bootstrap, as means to remove its toolchain dependency on C++, and yes I am aware of Cranelift.
> dealing with the urgent issues (namely packaging and memory safety) where C++ is losing to Rust.
There's a wisdom I got throughout life in various scenarios: You can't beat anyone in their own game. Currently memory safety is Rust's game. C++'s game is different: Being a high level language with tons of features, legacy (install base), a massive and well established ecosystem, and as a result of that shared knowledge.
Hence, from my personal perspective, C++ shall be C++. Getting useful features and cross-pollination is useful, but imitating or trying to beat something in its own game is waste of time and energy.
Because Rust and C++ are built different, and Rust's features doesn't replace battle-tested code. uutils shipped with 140CVEs at some point. That'll be my poster example for a very long time.