logoalt Hacker News

zarzavat • yesterday at 9:35 PM • 4 replies • view on HN

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.


Replies

BearOso • yesterday at 11:25 PM

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.

GuB-42 • yesterday at 11:22 PM

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.

➕ show 3 replies
Aerocatia • yesterday at 11:16 PM

I think the Common Package Specification goes a long way to fix packaging with C++ after trying it

guipsp • yesterday at 9:43 PM

Contracts are part of the memory safety story in c++

➕ show 3 replies