by zarzavat · 1w ago · 0 comments
The rejection was a moment for them to reevaluate their priorities but it doesn't seem that they've gotten the message.
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.
Safe C++ proposal (based on Circle compiler) was refused, and I don't believe in profiles as they are being sold, but lets see.
Even ubuntu's PPAs are just an extension of the trusted repository set.
This means snap and flatpack are the only "ecosystems" left and they are clearly not designed for programmers, which is why in this vacuum every programming language has its own ecosystem.
If you want cargo you also need the entire ecosystem to also adopt making everything MIT/BSD and that isn’t happening and no offence but if a project is setup and using CMake features from this decade you can just use CMake FetchContent to include it and build it.
Even boost can be included this way.
Why would you want to add more dependencies that are brittle and break?
Reduce friction for adding packages to a project, and everyone imports everything in a whim.
sudo-rs was pulling in a couple of million LOCs at one point. Yeah, most of it was unused at the end of the day, but it's a massive surface for something like sudo of all things.
Cargo culting is considered harmful.
> Languages bringing in their own packaging ecosystem via their tool always fall prey to something I call "leftpad syndrome"
I'm not aware of such problem in C#, for example.We have search engines and web registries, and they precede package managers mostly. Moreover, Linux distributions' repositories acted as a directory and everyone used these packages, which were not half-baked either.
It's not the optimal solution, but it's better than leftpad, proc-macro2 (and associated drama), and 5-link deep dependencies I have seen any programming language which has first-class packages support (incl. Go and Rust).
In my opinion, assembling a set of libraries by hand and vendoring them is way better than getting a logging library and pulling the whole world with it.
If c++ added something like fstring’s or C#’s $ string then I would be able to use that functionality in my multi million line code base, and as a language feature the compiler can do more with it than it can do with a random function call.
About half of the things I want from CPAN are available through distribution packages, and things will usually work when I use the distribution packages I can get and then install the rest from CPAN.
First, CPAN is old and is labor of an older generation of programmers who were attentive to that sort of problem. Language being Perl and having the same culture in it helped a lot as well.
Moreover, CPAN is available in distributions, as you say, and no distribution maintainer wants to package and ship a dependency hell, so this is a gentle but firm deterrent as well. Lastly, Perl's standard library is comprehensive for what it does, so it doesn't need leftpad style utilities as external libraries.
As a last resort, 3rd party package managers do exist. I don't use them unless I'm forced to use them, but they seem to have a shallower dependency tree, so problem is not as exaggerated as in package managers bundled with the languages themselves. Even gopls pulls in 24 more dependencies for its install. Nice.
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.
The doubt about C++ over Rust isn't well founded either. For instance, someone might be considering Rust solely because of dissatisfaction with packaging or memory safety in C++.
It's a variation of the "apples to oranges" metaphor which is just as stupid. Like, those are both fruits, so they have very similar possible uses, you absolutely can compare them! It's comparing, I don't know, toasters and umbrellas — yeah, that'd be silly, but only because the result of the comparison would be instantaneously apparent. You want toasted bread? Use a toaster. Protection from rain? An umbrella is obviously superior. Painting a roof? Both are equally useless.
So, Rust vs. C++? You want language features, you want tooling, you want the library ecosystem, you want the resulting programs' performance. All of those are things that the languages can, and should, be meaningfully compared with each other on.
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?
However, I think it’s insane to allow them to modify values. I get it probably really hard to prevent that in C++, but man is that going to be insanely hard to reason about.
No, C++ contracts have nothing to do with the type system. It is purely predicate calculus using Hoare logic where subsets of state space are filtered from a larger program state space. The program is basically "steered" through the global state space using pre/post conditions.
Note however that theoretically (i.e. following from Curry-Howard correspondence) contracts can be thought of as dynamic counterparts to dependent types. But that is in a functional language with typing using constructive logic and not in an imperative language.
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.
Which it did long ago.
> To me, the point of C++ is: "I want to write C, but I also want feature X"
You are part of a small minority.
(The two most famous examples of this are type punning, which is well-defined in C but not in C++, and infinite loops without side effects, which were UB in C++ until this year because of C++'s stricter forward progress guarantee.)
C is not memory safe and will never be
On the contrary, C is far more easily made memory safe than C++, because it's a much simpler language with almost entirely explicit control flow. You have fil-c, CMBC, TIS that all work today, not to mention the profusion of annotation-based tools that have existed for years. Galois is working on C2Rust and other tools, though they're not fully safe/general yet.Your options for C++ essentially amount to sanitizers, less-accurate static analysis work, and paying experts like TIS for manual verification. C++ is also choosing to actively make the problem worse when it deliberately refrains from adopting C's verifiability improvements, like prohibiting time-traveling UB. It's not like this is solely a problem of legacy standards either. std::span could have been safe (as gsl::span is), but the decision was made to deliberately sacrifice safety for other considerations.
How many of those are at runtime vs compile time?
While the philosophy of C++ is "C with extra features", and it certainly delivers on extra features, C is all about simplicity and compatibility.
You want to touch C as little as possible. There are who knows how many thousands of C compilers for obscure platforms and decades old legacy code that all depend on C being stable. The industry mostly leave C alone not because they don't have the resources, but because the world runs on C and they certainly don't want to break things that work!
If what you want is a simple, explicit language that is well suited for system and embedded programming while being more modern than C, there is Zig.
I like to say that Zig is to C what Rust is to C++.
Except for all the ways in which it isn't, which are more applicable to the average codebase than any of those tools.
I don't think you need a separate committee. There were efforts to create a standardized packaging system through the committee, but the author decided to pursue a different path outside of the committee after it was clear that the committee's priorities were elsewhere.
CMake 4.5 is the first stable release with support for it, and it still needs to widespread.
The way I see it languages are industrial ecosystems.
There are several good reasons why a language should have "it's own" compiler chain.
While C++ is not going to disappear, piggybacking on C++ infrastructure means that Rust is not really standing on it's own feet institutionally or technologically.
These two have lots of second order effects as I see it. But the topic is too complex to fit to a brief comment :)
To me, the things you describe might be nice to have, and I certainly could understand a language choosing a set of goals that makes those an actual requirement, but I have yet to hear of Rust devs taking that particular stance.
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.
The pushback from the final rejection got the committee to add the bare minimum that could help C++’s safety story.
So the “fix” was to let the author mark individual contracts as always enforced at runtime, with pre<enforced>. That, in turn, means a library’s key safety checks (bounds, null, etc.) can’t be silently dropped in a “loose” build configuration, which pushes things down a safer path.
Clunky IMO, but rather reasonable as a response to Rust!
It brings things closer to a world where: if you use these “safe” libraries, your program will stop rather than run unsafely, no matter how it was built.
Now if the contract was instead, it must be proved at compile time I'd be for that. I don't know if theorem checkers are good enough to pull that off.
If statements can do guaranteed enforcement of bounds och null checks.
What they added is no different in practice to what contracts already were before. If a compiler adds `-fno-contracts` then they will not be enforced, which was already the case.
But hey, if it helps C++ make it past the ISO process then it will have been a value-added change even though it's not actually any different.
If the feature is irredeemably broken as opponents claim to be, what does a glorified rehearsal session changed?
I think this outcome is the worst outcome possible. Contracts proponents seem to have doubled down and hell bent on playing a game of political chicken. It's plausible the same proposal will be rejected again on the same grounds, with the same string of personal attacks that followed it.
Contracts are an optional debugging tool. They are literally designed to assert pre and post conditions. They are no better than the assert macro in asserting memory safety.
The two features you list don't have to depend on contracts, and in fact didn't do so at first. The dependency was only added later, and there were efforts to undo such a change right to the end.
Furthermore, IIRC hardening only relies on the contracts system to report precondition violations. The actual checks are intentionally not contract assertions and are intentionally not controlled via the same system as other contract assertions (i.e., hardened checks remain even if you use "ignore" as your contract evaluation semantic).
The most trivial example of this is a check that a caller has provided non-null inputs ( hence allowing 'safe' unchecked access in most cases)
Except this isn't true, and it's at best an unfounded belief that relies on hand waving and wishful thinking to connect how an optional debugging tool that affects memory allocation and is able to throw exceptions will save anyone from things such as use-after-free.