19 comments

  • suby7 hours ago
    I am somewhat dismayed that contracts were accepted. It feels like piling on ever more complexity to a language which has already surpassed its complexity budget, and given that the feature comes with its own set of footguns I&#x27;m not sure that it is justified.<p>Here&#x27;s a quote from Bjarne,<p>&gt; So go back about one year, and we could vote about it before it got into the standard, and some of us voted no. Now we have a much harder problem. This is part of the standard proposal. Do we vote against the standard because there is a feature we think is bad? Because I think this one is bad. And that is a much harder problem. People vote yes because they think: &quot;Oh we are getting a lot of good things out of this.&quot;, and they are right. We are also getting a lot of complexity and a lot of bad things. And this proposal, in my opinion is bloated committee design and also incomplete.
    • addaon7 hours ago
      I can’t speak to the C++ contract design — it’s possible bad choices were made. But contracts in general are absolutely exactly what C++ needs for the next step of its evolution. Programming languages used for correct-by-design software (Ada, C++, Rust) need to enable deep integration with proof assistants to allow showing arbitrary properties statically instead of via testing, and contracts are &#x2F;the&#x2F; key part of that — see e.g. Ada Spark.
      • derriz7 hours ago
        C++ is the last language I&#x27;d add to any list of languages used for correct-by-design - it&#x27;s underspecified in terms of semantics with huge areas of UB and IB. Given its vast complexity - at every level from the pre-processor to template meta-programming and concepts, I simply can&#x27;t imagine any formal denotational definition of the language ever being developed. And without a formal semantics for the language, you cannot even start to think about proof of correctness.
        • addaon6 hours ago
          As with Spark, proving properties over a subset of the language is sufficient. Code is written to be verified; we won’t be verifying interesting properties of large chunks of legacy code in my career span. The C (near-) subset of C++ is (modulo standard libraries) a starting point for this; just adding on templates for type system power (and not for other exotic uses) goes a long way.
      • kajaktum2 hours ago
        C++ needs to give itself up and make way for other, newer, modern, language that have far, far fewer baggage. It should be working with other language to provide tools for interop and migration.<p>C++ will never, ever be modern and comprehensible because of 1 and 1 reason alone: backward compatibility.<p>It does not matter what version of C++ you are using, you are still using C with classes.
        • Guvante2 hours ago
          Why should C++ stop improving? Other languages don&#x27;t need C++ to die to beat it.
      • bluGill7 hours ago
        The people who did contracts are aware of ada&#x2F;spark and some have experience using it. Only time will tell if it works in c++ but they at least did all they could to give it a chance.<p>Note that this is not the end of contrats. This is a minimun viable start that they intend to add to but the missing parts are more complex.
        • dislikedopinion7 hours ago
          Might be the case that Ada folks successfully got a bad version of contracts not amenable for compile-time checking into C++, to undermine the competition. Time might tell.
          • stackghost6 hours ago
            I strongly doubt that C++ is what&#x27;s standing in the way of Ada being popular.
            • dislikedopinion5 hours ago
              Ada used to be mandated in the US defense industry, but lots of developers and companies preferred C++ and other languages, and for a variety of reasons, the mandate ended, and Ada faded from the spotlight.
              • stackghost5 hours ago
                &gt;the mandate ended, and Ada faded from the spotlight<p>Exactly. People stopped using Ada as soon as they were no longer forced to use it.<p>In other words on its own merits people don&#x27;t choose it.
                • hansvm5 hours ago
                  On their own merits, people choose SMS-based 2FA, &quot;2FA&quot; which lets you into an account without a password, perf-critical CLI tools written in Python, externalizing the cost of hacks to random people who aren&#x27;t even your own customers, eating an extra 100 calories per day, and a whole host of other problematic behaviors.<p>Maybe Ada&#x27;s bad, but programmer preference isn&#x27;t a strong enough argument. It&#x27;s just as likely that newer software is buggier and more unsafe or that this otherwise isn&#x27;t an apples-to-apples comparison.
                  • stackghost4 hours ago
                    I made no judgement about whether Ada is subjectively &quot;bad&quot; or not. I used it for a single side project many years ago, and didn&#x27;t like it.<p>But my anecdotal experience aside, it is plain to see that developers had the opportunity to continue with Ada and largely did not once they were no longer required to use it.<p>So, it is exceedingly unlikely that some conspiracy against C++, motivated by mustache-twirling Ada gurus, is afoot. And <i>even if that were true</i>, knocking C++ down several pegs will not make people go back to Ada.<p>C#, Rust, and Go all exist and are all immensely more popular than Ada. If there were to be a sudden exodus of C++ developers, these languages would likely be the main beneficiaries.<p>My original point, that C++ isn&#x27;t what&#x27;s standing in the way of Ada being popular, still stands.
          • steveklabnik6 hours ago
            This is some pretty major conspiracy thinking, and would need some serious evidence. Do you have any?
            • dislikedopinion5 hours ago
              [flagged]
              • steveklabnik5 hours ago
                Okay, on one hand, I&#x27;m very curious, but on the other hand, not really on topic for this forum. So I&#x27;ll just leave a &quot;wut&quot;.
      • wpollock5 hours ago
        &gt; Programming languages used for correct-by-design software (Ada, C++, Rust) ...<p>A shoutout to Eiffel, the first &quot;modern&quot; (circa 1985) language to incorporate Design by Contract. Well done Bertrand Meyer!
      • StilesCrisis7 hours ago
        Right, I think the tension here is that we would like contracts to exist in the language, but the current design isn&#x27;t what it needs to be, and once it&#x27;s standardized, it&#x27;s extremely hard to fix.
      • steveklabnik6 hours ago
        The devil is in the details, because standardization work is all about details.<p>From my outside vantage point, there seems to be a few different camps about what is desired for contracts to even <i>be</i>. The conflict between those groups is why this feature has been contentious for... a decade now?<p>Some of the pushback against this form of contracts is from people who desire contracts, but don&#x27;t think that this design is the one that they want.
      • quotemstr6 hours ago
        But why? You can do everything contracts do in your own code, yes? Why make it a language feature? I&#x27;m not against growing the language, but I don&#x27;t see the necessity of this specific feature having new syntax.
        • spacechild16 hours ago
          Pre- and postconditions are actually part of the function signature, i.e. they are visible to the caller. For example, static analyzers could detect contract violations just by looking at the callsite, without needing access to the actual function implementation. The pre- and postconditions can also be shown in IDE tooltips. You can&#x27;t do this with your own contracts implementation.<p>Finally, it certainly helps to have a standardized mechanisms instead of everyone rolling their own, especially with multiple libraries.
          • kevin_thibedeau2 hours ago
            Is a pointer parameter an input, output, or both?
            • drfloyd514 minutes ago
              Input.<p>You are passing in a memory location that can be read or written too.<p>That’s it.
              • kevin_thibedeau2 minutes ago
                A pointer doesn&#x27;t necessarily point to memory.
        • addaon6 hours ago
          Contracts are about specifying static properties of the system, not dynamic properties. Features like assert &#x2F;check&#x2F; (if enabled) static properties, at runtime. static_assert comes closer, but it’s still an awkward way of expressing Hoare triples; and the main property I’m looking for is the ability to easily extract and consider Hoare triples from build-time tooling. There are hacky ways to do this today, but they’re not unique hacky ways, so they don’t compose across different tools and across code written to different hacks.
        • jevndev6 hours ago
          The common argument for a language feature is for standardization of how you express invariants and pre&#x2F;post conditions so that tools (mostly static tooling and optimizers) can be designed around them.<p>But like modules and concepts the committee has opted for staggered implementation. What we have now is effectively syntax sugar over what could already be done with asserts, well designed types and exceptions.
        • jandrewrogers6 hours ago
          DYI contracts don&#x27;t compose when mixing code using different DYI implementations. Some aspects of contracts have global semantics.
    • zzzoom1 hour ago
      That&#x27;s a genius idea, keep adding broken stuff into the standard until there&#x27;s no choice but to break compatibility to fix it.
    • jandrewrogers6 hours ago
      C++ contracts standardizes what people already do in C++. Where is the complexity in that? It removes the need to write your own implementation because the language provides a standard interoperable one.<p>An argument can be made that C++26 features like reflection add complexity but I don&#x27;t follow that argument for contracts.
    • ghighi78784 hours ago
      Just because Bjarne thinks the feature is bad doesnt mean it is bad. He can be wrong. The point is, most peoppe disagree with him, and so a lot of peoppe do think it is good.
      • gmueckl4 hours ago
        There have been several talks about contracts and the somewhat hidden complexities in them. C++ contracts are not like what you&#x27;d initally expect. Compiler switches can totally alter how contracts behave from getting omitted to reporting failures to aborting the program. There is also an optional global callback for when a contract check fails.<p>Different TUs can be compiled with different settings for the contract behavior. But can they be binary compatible? In general, no. If a function is declared in-line in a header, the comoiler may have generated two different versions with different contract behaviors, which violates ODR.<p>What happens if the contract check calls a helper function that throws an exception?<p>The whole things is really, really complex and I don&#x27;t assume that I understand it properly. But I can see that there are some valid concerns against the feature as standardized and that makes me side with the opposition here: this was not baked enough yet
        • btilly24 minutes ago
          That sounds like the worst kind of misfeature.<p>It sounds like it should solve your problem. At first it seems to work. Then you keep on finding the footguns after it is too late to change the design.
        • nulltrace4 hours ago
          Coroutines went through the same cycle. Standardized in C++20, and I still hit compiler-specific differences in how symmetric transfer gets lowered.
    • DenisM4 hours ago
      &gt;to a language which has already surpassed its complexity budget<p>I&#x27;ve been thinking that way for many years now, but clearly I&#x27;ve been wrong. Perhaps C++ is the one language to which the issue of excess complexity does not apply.
      • selfmodruntime4 hours ago
        In essence, a standard committee thinks like bureaucrats. They have little to no incentive to get rid of cruft and only piling on new stuff is rewarded.
    • devnullbrain5 hours ago
      Source of quote:<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;tzXu5KZGMJk?t=3160" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;tzXu5KZGMJk?t=3160</a>
    • Waterluvian5 hours ago
      Has any project ever tried to quantify a “complexity budget” and stick to it?<p>I’m fascinated by the concept of deciding how much complexity (to a human) a feature has. And then the political process of deciding what to remove when everyone agrees something new needs to be accepted.
    • raincole7 hours ago
      I mean... it&#x27;s C++. The complexity budget is like the US government&#x27;s debt ceiling.
    • seertaak6 hours ago
      Can you share what aspects of the design you (and Stroustroup) aren&#x27;t happy with? Stroustroup has a tendency of being proven right, with 1-3 decade lag.
      • tialaramex3 hours ago
        Certainly we can say that Bjarne will insist he was right decades later. We can&#x27;t necessarily guess - at the time - what it is he will have &quot;always&quot; believed decades later though.
      • ghighi78784 hours ago
        Well thats not always true. Initializer list is a glaring example. So are integer promotion some other things like
    • Maxatar6 hours ago
      Without a significant amount of needed context that quote just sounds like some awkward rambling.<p>Also almost every feature added to C++ adds a great deal of complexity, everything from modules, concepts, ranges, coroutines... I mean it&#x27;s been 6 years since these have been standardized and all the main compilers still have major issues in terms of bugs and quality of implementation issues.<p>I can hardly think of any major feature added to the language that didn&#x27;t introduce a great deal of footguns, unintended consequences, significant compilation performance issues... to single out contracts is unusual to say the least.
  • jcalvinowens6 hours ago
    The &quot;erroneous behavior&quot; redefinition for reads of uninitialized variables is really interesting: <a href="https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg21&#x2F;docs&#x2F;papers&#x2F;2024&#x2F;p2795r5.html" rel="nofollow">https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg21&#x2F;docs&#x2F;papers&#x2F;2024&#x2F;p27...</a><p>It does have a runtime cost. There&#x27;s an attribute to force undefined behavior on read again and avoid the cost:<p><pre><code> int x [[indeterminate]]; std::cin &gt;&gt; x;</code></pre>
    • augusto-moura2 hours ago
      Hm, I wonder if this will be a compiler flag too, probably yes, since some projects would prefer to init all variables by hand anyway.
  • LatencyKills8 hours ago
    This is awesome. I&#x27;ve was a dev on the C++ team at MS in the 90s and was sure that RTTI was the closest the language would ever get to having a true reflection system.
  • dataflow7 hours ago
    &gt; Second, conforming compiler and standard library implementations are coming quickly. Throughout the development of C++26, at any given point both GCC and Clang had already implemented two-thirds of C++26 features. Today, GCC already has reflection and contracts merged in trunk, awaiting release.<p>How far is Clang on reflection and contracts?
    • cpeterso5 hours ago
      Clang’s C++2c implementation status page simply says “no” for both reflection and contracts. GCC’s says “yes”.<p><a href="https:&#x2F;&#x2F;clang.llvm.org&#x2F;cxx_status.html" rel="nofollow">https:&#x2F;&#x2F;clang.llvm.org&#x2F;cxx_status.html</a><p><a href="https:&#x2F;&#x2F;gcc.gnu.org&#x2F;projects&#x2F;cxx-status.html" rel="nofollow">https:&#x2F;&#x2F;gcc.gnu.org&#x2F;projects&#x2F;cxx-status.html</a>
      • dataflow45 minutes ago
        That much I&#x27;m aware, but that&#x27;s just about feature availability. I was wondering how far the implementations have progressed internally, despite the features being unavailable.
  • mohamedkoubaa8 hours ago
    Biggest open question is whether the small changes to the module system in this standard will actually lead to more widespread adoption
    • zarzavat8 hours ago
      The best thing the C++ WG could do is to spend an entire release cycle working on modules and packaging.<p>It&#x27;s nice to have new features, but what is really killing C++ is Cargo. I don&#x27;t think a new generation of developers are going to be inspired to learn a language where you can&#x27;t simply `cargo add` whatever you need and instead have to go through hell to use a dependency.
      • saghm6 hours ago
        To me, the most important feature of Cargo isn&#x27;t even the dependency management but that I don&#x27;t ever need to tell it which files to compile or where to find them. The fact that it knows to look for lib.rs or main.rs in src and then recursively find all my other modules without me needing to specify targets or anything like that is a killer feature on its own IMO. Over the past couple of years I&#x27;ve tried to clone and build a number of dotnet packages for various things, but for an ecosystem that&#x27;s supposedly cross-platform, almost none of them seem to just work by default when I run `dotnet build` and instead require at least some fixes in the various project files. I don&#x27;t think I&#x27;ve ever had an issue with a Rust project, and it&#x27;s hard not to feel like a big part of that is because there&#x27;s not really much configuration to be done. The list of dependencies is just about the only thing in there that effects the default build; if there&#x27;s any other configuration other than that and the basic metadata like the name, the repo link, the license, etc., it almost always will end up being specifically for alternate builds (like extra options for release builds, alternate features that can be compiled in, etc.).
        • kibwen4 hours ago
          <i>&gt; The fact that it knows to look for lib.rs or main.rs in src and then recursively find all my other modules without me needing to specify targets or anything like that is a killer feature on its own IMO.</i><p>In the interest of pedantry, locating source files relative to the crate root is a language-level Rust feature, not something specific to Cargo. You can pass any single Rust source file directly to rustc (bypassing Cargo altogether) and it will treat it as a crate root and locate additional files as needed based on the normal lookup rules.
          • saghm6 minutes ago
            Interesting, I didn&#x27;t realize this! I know that a &quot;crate&quot; is specifically the unit of compilation for rustc, but I assumed there was some magic in cargo that glued the modules together into a single AST rather than it being in rustc itself.<p>That being said, I&#x27;d argue that the fact that this happens so transparently that people don&#x27;t really need to know this to use Cargo correctly is somewhat the point I was making. Compared to something like cmake, the amount of effort to use it is at least an order of magnitude lower.
        • nicoburns1 hour ago
          &gt; I don&#x27;t think I&#x27;ve ever had an issue with a Rust project, and it&#x27;s hard not to feel like a big part of that is because there&#x27;s not really much configuration to be done.<p>For most crates, yes. But you might be surprised how many crates have a build.rs that is doing more complex stuff under the hood (generating code, setting environment variables, calling a C compiler, make or some other build system, etc). It just also almost always works flawlessly (and the script itself has a standardised name), so you don&#x27;t notice most of the time.
          • saghm3 minutes ago
            True, but if anything, a build.rs is a lot easier for me to read and understand (or even modify) if needed because I already know Rust. With something like cmake, the build configuration is an entirely separate language the one I&#x27;m actually working in, and I haven&#x27;t seen a project that doesn&#x27;t have at least <i>some</i> amount of custom configuration in it. Starting up a cargo project literally doesn&#x27;t require putting anything in the Cargo.toml that doesn&#x27;t exist after you run `cargo new`.
        • scrubs4 hours ago
          Yep ... go&#x2F;zig pkg management has the same benefit compared to c&#x2F;c++.
        • vlovich1236 hours ago
          For me the lack of dependency hell until I hit a c&#x2F;c++ component somewhere in the build is the real winner.
      • ho_schi7 hours ago
        I’m still surprised how people ignore Meson. Please test it :)<p><a href="https:&#x2F;&#x2F;mesonbuild.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mesonbuild.com&#x2F;</a><p>And Mesons awesome dependency handling:<p><a href="https:&#x2F;&#x2F;mesonbuild.com&#x2F;Dependencies.html" rel="nofollow">https:&#x2F;&#x2F;mesonbuild.com&#x2F;Dependencies.html</a><p><a href="https:&#x2F;&#x2F;mesonbuild.com&#x2F;Using-the-WrapDB.html#using-the-wrapdb" rel="nofollow">https:&#x2F;&#x2F;mesonbuild.com&#x2F;Using-the-WrapDB.html#using-the-wrapd...</a><p><a href="https:&#x2F;&#x2F;nibblestew.blogspot.com&#x2F;2026&#x2F;02&#x2F;c-and-c-dependencies-dont-dream-it-be-it.html" rel="nofollow">https:&#x2F;&#x2F;nibblestew.blogspot.com&#x2F;2026&#x2F;02&#x2F;c-and-c-dependencies...</a><p>I suffered with Java from Any, Maven and Gradle (the oldest is the the best). After reading about <i>GNU Autotools</i> I was wondering why the C&#x2F;C++ folks still suffer? Right at that time Meson appeared and I skipped the suffering.<p><pre><code> * No XML * Simple to read and understand * Simple to manage dependencies * Simple to use options </code></pre> Feel free to extend WrapDB.
        • PerryStyle4 hours ago
          Meson is indeed nice, but has very poor support for GPU compilation compared to CMake. I&#x27;ve had a lot of success adopting the practices described in this talk, <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=K5Kg8TOTKjU" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=K5Kg8TOTKjU</a>. I thought I knew a lot of CMake, but file sets definitely make things a lot simpler.
        • light_hue_16 hours ago
          Meson merges the crappy state of C&#x2F;C++ tooling with something like Cargo in the worst way possible: by forcing you to handle the complexity of both. Nothing about Meson is simple, unless you&#x27;re using it in Rust, in which case you&#x27;re better off with Cargo.<p>In C++ you don&#x27;t get lockfiles, you don&#x27;t get automatic dependency install, you don&#x27;t get local dependencies, there&#x27;s no package registry, no version support, no dependency-wide feature flags (this is an incoherent mess in Meson), no notion of workspaces, etc.<p>Compared to Cargo, Meson isn&#x27;t even in the same galaxy. And even compared to CMake, Meson is yet another incompatible incremental &quot;improvement&quot; that offers basically nothing other than cute syntax (which in an era when AI writes all of your build system anyway, doesn&#x27;t even matter). I&#x27;d much rather just pick CMake and move on.
        • einpoklum6 hours ago
          Build system generators (like Meson, autotools, CMake or any other one) can&#x27;t solve programming language module and packaging problems, even in principle. So, it&#x27;s not clear what your argument is here.<p>&gt; I’m still surprised how people ignore Meson. Please test it :)<p>I did just that a few years ago and found it rather inconvenient and inflexible, so I went back to ignoring it. But YMMV I suppose.<p>&gt; After reading about GNU Autotools<p>Consider Kitware&#x27;s CMake.
      • luka5987 hours ago
        Agreed, arcane cmake configs and or bash build scripts are genuinely off-putting. Also cpp &quot;equivalents&quot; of cargo which afaik are conan and vcpkg are not default and required much more configuring in comparison with cargo. Atleast this was my experience few years ago.
        • mgaunard7 hours ago
          It&#x27;s fundamentally different; Rust entirely rejects the notion of a stable ABI, and simply builds everything from source.<p>C and C++ are usually stuck in that antiquated thinking that you should build a module, package it into some libraries, install&#x2F;export the library binaries and associated assets, then import those in other projects. That makes everything slow, inefficient, and widely dangerous.<p>There are of course good ways of building C++, but those are the exception rather than the standard.
          • jjmarr5 hours ago
            &quot;Stable ABI&quot; is a joke in C++ because you can&#x27;t keep ABI and change the implementation of a templated function, which blocks improvements to the standard library.<p>In C, ABI = API because the declaration of a function contains the name and arguments, which is all the info needed to use it. You can swap out the definition without affecting callers.<p>That&#x27;s why Rust allows a stable C-style ABI; the definition of a function declared in C doesn&#x27;t have to be in C!<p>But in a C++-style templated function, the caller needs access to the <i>definition</i> to do template substitution. If you change the definition, you need to recompile calling code i.e. ABI breakage.<p>If you <i>don&#x27;t</i> recompile calling code and link with other libraries that are using the new definition, you&#x27;ll violate the one-definition rule (ODR).<p>This is bad because duplicate template functions are pruned at link-time for size reasons. So it&#x27;s a mystery as to what definition you&#x27;ll get. Your code will break in mysterious ways.<p>This means the C++ committee can never change the implementation of a standardized templated class or function. The only time they did was a minor optimization to std::string in 2011 and it was such a catastrophe they never did it again.<p>That is why Rust will not support stable ABIs for any of its features relying on generic types. It is impossible to keep the ABI stable and optimize an implementation.
          • zrm6 hours ago
            &gt; C and C++ are usually stuck in that antiquated thinking that you should build a module, package it into some libraries, install&#x2F;export the library binaries and associated assets, then import those in other projects. That makes everything slow, inefficient, and widely dangerous.<p>It seems to me the &quot;convenient&quot; options are the dangerous ones.<p>The traditional method is for third party code to have a stable API. Newer versions add functions or fix bugs but existing functions continue to work as before. API mistakes get deprecated and alternatives offered but newly-deprecated functions remain available for 10+ years. With the result that you can link all applications against any sufficiently recent version of the library, e.g. the latest stable release, which can then be installed via the system package manager and have a manageable maintenance burden because only one version needs to be maintained.<p>Language package managers have a tendency to facilitate breaking changes. You &quot;don&#x27;t have to worry&quot; about removing functions without deprecating them because anyone can just pull in the older version of the code. Except the older version is no longer maintained.<p>Then you&#x27;re using a version of the code from a few years ago because you didn&#x27;t need any of the newer features and it hadn&#x27;t had any problems, until it picks up a CVE. Suddenly you have vulnerable code running in production but fixing it isn&#x27;t just a matter of &quot;apt upgrade&quot; because no one else is going to patch the version only you were using, and the current version has several breaking changes so you can&#x27;t switch to it until you integrate them into your code.
            • mgaunard2 hours ago
              This is all wishful thinking disconnected from practicalities.<p>First you confuse API and ABI.<p>Second there is no practical difference between first and third-party for any sufficiently complex project.<p>Third you cannot have multiple versions of the same thing in the same program without very careful isolation and engineering. It&#x27;s a bad idea and a recipe for ODR violations.<p>In any non-trivial project there will be complex dependency webs across different files and subprojects, and humans are notoriously bad at packaging pieces of code into sensible modules, libraries or packages, with well-defined and maintained boundaries. Being able to maintain ABI compatibility, deprecating things while introducing replacement etc. is a massive engineering work and simply makes people much less likely to change the way things are done, even if they are broken or not ideal. That&#x27;s an effort you&#x27;ll do for a kernel (and only on specific boundaries) but not for the average program.
          • tialaramex6 hours ago
            It&#x27;s not true that Rust rejects &quot;the notion of a stable ABI&quot;. Rust rejects the C++ solution of freeze everything and hope because it&#x27;s a disaster, it&#x27;s less stable than some customers hoped and yet it&#x27;s frozen in practice so it disappoints others. Rust says an ABI should be a promise by a developer, the way its existing C ABI is, that you can <i>explicitly</i> make or not make.<p>Rust is interested in having a properly thought out ABI that&#x27;s nicer than the C ABI which it supports today. It&#x27;d be nice to have say, ABI for slices for example. But &quot;freeze everything and hope&quot; isn&#x27;t that, it means every user of your language into the unforeseeable future has to pay for every mistake made by the language designers, and that&#x27;s already a sizeable price for C++ to pay, &quot;ABI: Now or never&quot; spells some of that out and we don&#x27;t want to join them.
            • zozbot2343 hours ago
              &gt; It&#x27;d be nice to have say, ABI for slices for example.<p>The de-facto ABI for slices involves passing&#x2F;storing pointer and length separately and rebuilding the slice locally. It&#x27;s hard to do better than that other than by somehow standardizing a &quot;slice&quot; binary representation across C and C-like languages. And then you&#x27;ll still have to deal with existing legacy code that doesn&#x27;t agree with that strict representation.
          • NetMageSCW7 hours ago
            I would suggest importing binaries and metadata is going to be faster than compiling all the source for that.
            • mgaunard2 hours ago
              You&#x27;d be wrong. If the build system has full knowledge on how to build the whole thing, it can do a much better job. Caching the outputs of the build is trivial.<p>If you import some ready made binaries, you have no way to guarantee they are compatible with the rest of your build or contain the features you need. If anything needs updating and you actually bother to do it for correctness (most would just hope it&#x27;s compatible) your only option is usually to rebuild the whole thing, even if your usage only needed one file.
          • uecker5 hours ago
            &quot;That makes everything slow, inefficient, and widely dangerous.&quot;<p>There nothing faster and more efficient than building C programs. I also not sure what is dangerous in having libraries. C++ is quite different though.
            • hansvm4 hours ago
              Of course there is. Raw machine code is the gold standard, and everything else is an attempt to achieve _something_ at the cost of performance, C included, and that&#x27;s even when considering whole-program optimization and ignoring the overhead introduced by libraries. Other languages with better semantics frequently outperform C (slightly) because the compiler is able to assume more things about the data and instructions being manipulated, generating tighter optimizations.
            • mgaunard3 hours ago
              ODR violations are very easy to trigger unless you build the whole thing from source, and are ill-formed, no diagnostic required (worse than UB).
          • stackghost7 hours ago
            &gt;There are of course good ways of building C++, but those are the exception rather than the standard.<p>What are the good ways?
            • mgaunard4 hours ago
              Build everything from source within a single unified workspace, cache whatever artifacts were already built with content-addressable storage so that you don&#x27;t need to build them again.<p>You should also avoid libraries, as they reduce granularity and needlessly complexify the logic.<p>I&#x27;d also argue you shouldn&#x27;t have any kind of declaration of dependencies and simply deduce them transparently based on what the code includes, with some logic to map header to implementation files.
              • maccard3 hours ago
                The problem is doing this requires a team to support it that is realistically as large as your average product team. I know Bazel is the solution here but as someone who has used C++, modified build systems and maintained CI for teams for years, I have never gotten it to work for anything more than a toy project.
                • mgaunard2 hours ago
                  I have several times built my own system to do just that when it wasn&#x27;t even my main job. Doesn&#x27;t take more than a couple of days.<p>Bazel is certainly not the solution; it&#x27;s arguably closer to being the problem. The worst build system I have ever seen was Bazel-based.
              • stackghost3 hours ago
                &gt;Build everything from source within a single unified workspace, cache whatever artifacts were already built with content-addressable storage so that you don&#x27;t need to build them again.<p>Which tool do you use for content-addressable storage in your builds?<p>&gt;You should also avoid libraries, as they reduce granularity and needlessly complexify the logic.<p>This isn&#x27;t always feasible though.<p>What&#x27;s the best practice when one cannot avoid a library?
                • mgaunard2 hours ago
                  You can use S3 or equivalent; a normal filesystem (networked or not) also works well.<p>You hash all the inputs that go into building foo.cpp, and then that gives you &#x2F;objs&#x2F;&lt;hash&gt;.o. If it exists, you use it; if not, you build it first. Then if any other .cpp file ever includes foo.hpp (directly or indirectly), you mark that it needs to link &#x2F;objs&#x2F;&lt;hash&gt;.o.<p>You expand the link requirements transitively, and you have a build system. 200 lines of code. Your code is self-describing and you never need to write any build logic again, and your build system is reliable, strictly builds only what it needs while sharing artifacts across the team, and never leads to ODR.
            • lstodd5 hours ago
              &quot;Do not do it&quot; looks like the winning one nowadays.
      • daemin2 hours ago
        I may be in the minority but I like that C++ has multiple package managers, as you can use whichever one best fits your use case, or none at all if your code is simple enough.<p>It&#x27;s the same with compilers, there&#x27;s not one single implementation which is <i>the</i> compiler, and the ecosystem of compilers makes things more interesting.
        • lmm1 hour ago
          Multiple package managers is fine, what&#x27;s needed is a common repository standard (or even any repository functionality at all). Look at how it works in Java land, where if you don&#x27;t want to use Maven you can use Gradle or Bazel or what have you, or if you hate yourself you can use Ant+Ivy, but all of them share the same concept of what a dependency is and can use the same repositories.
          • zarzavat28 minutes ago
            Also, having one standard packaging format and registry doesn&#x27;t preclude having alternatives for special use cases.<p>There should be a happy path for the majority of C++ use cases so that I can make a package, publish it and consume other people&#x27;s packages. Anyone who wants to leave that happy path can do so freely at their own risk.<p>The important thing is to get one system blessed as The C++ Package Format by the standard to avoid xkcd 927 issues.
      • mgaunard7 hours ago
        In my experience, no one does build systems right; Cargo included.<p>The standard was initially meant to standardize existing practice. There is no good existing practice. Very large institutions depending heavily on C++ systematically fail to manage the build properly despite large amounts of third party licenses and dedicated build teams.<p>With AI, how you build and integrate together fragmented code bases is even more important, but someone has yet to design a real industry-wide solution.
        • lenkite7 hours ago
          Speedy convenience beats absolute correctness anyday. Humans are not immortal and have finite amount of time for life and work. If convenience didn&#x27;t matter, we would all still be coding in assembly or toggling hardware switches.
          • jjmarr6 hours ago
            C++ builds are extremely slow because they are not correct.<p>I&#x27;m doing a migration of a large codebase from local builds to remote execution and I constantly have bugs with mystery shared library dependencies implicitly pulled from the environment.<p>This is extremely tricky because if you run an executable without its shared library, you get &quot;file not found&quot; with no explanation. Even AI doesn&#x27;t understand this error.
            • mgaunard2 hours ago
              The dynamic linker can clearly tell you where it looks for files and in which order, and where it finds them if it does.<p>You can also very easily harden this if you somehow don&#x27;t want to capture libraries from outside certain paths.<p>You can even build the compiler in such a way that every binary it produces has a built-in RPATH if you want to force certain locations.
              • jjmarr2 hours ago
                That is what I&#x27;m doing so I can get distributed builds working. It sucks and has taken me days of work.
          • morning-coffee5 hours ago
            The Mars Polar Lander and Mars Climate Orbiter missions would beg to differ.<p>(And &quot;absolute&quot; or other adjectives don&#x27;t qualify &quot;correctness&quot;... it simply is or isn&#x27;t.)
      • groundzeros20157 hours ago
        I didn’t think header only was that bad - now we have a nightmare of incompatible standards and compilers.
    • jjmarr8 hours ago
      No, because most major compilers don&#x27;t support header units, much less standard library header units from C++26.<p>What&#x27;ll spur adoption is cmake adopting Clang&#x27;s two-step compilation model that increases performance.<p>At that point every project will migrate overnight for the huge build time impact since it&#x27;ll avoid redundant preprocessing. Right now, the loss of parallelism ruins adoption too much.
    • forrestthewoods8 hours ago
      No. Modules are a failed idea. Really really hard for me to see them becoming mainstream at this point.
      • m-schuetz8 hours ago
        The idea is great, the execution is terrible. In JS, modules were instantly popular because they were easy to use, added a lot of benefit, and support in browsers and the ecoysystem was fairly good after a couple of years. In C++, support is still bad, 6 years after they were introduced.
        • evanmoran6 hours ago
          Exactly. C++ is still waiting for its &quot;uv&quot; moment, so until then modules aren&#x27;t even close to solved.
          • lostdog5 hours ago
            And uv required some ground work, where the PEP process streamlined how you define a python project, and then uv could be built on top.
      • Xraider727 hours ago
        No idea if modules themselves are failed or no, but if c++ wants to keep fighting for developer mindshare, it must make something resembling modules work and figure out package management.<p>yes you have CPM, vcpkg and conan, but those are not really standard and there is friction involved in getting it work.
        • StilesCrisis7 hours ago
          Much like contracts--yes, C++ needs something modules-like, but the actual design as standardized is not usable.<p>Once big companies like Google started pulling out of the committee, they lost their connection to reality and now they&#x27;re standardizing things that either can&#x27;t be implemented or no one wants as specced.
        • forrestthewoods5 hours ago
          I emphatically agree. C++ needs a standard build system that doesn’t suck ass. Most people would agree it needs a package manager although I think that is actually debatable.<p>Neither of those things require modules as currently defined.
      • AyanamiKaine7 hours ago
        Can you explain why you think modules are a failed idea? Because not that many use them right now?<p>Personally I use them in new projects using XMake and it just works.
        • devnullbrain5 hours ago
          I&#x27;m not the PC but I think you miss most of the pain points due to: &#x27;personal&#x27; projects.<p>There&#x27;s not a compatible format between different compilers, or even different versions of the same compiler, or even the same versions of the same compiler with different flags.<p>This seems immediately to create too many permutations of builds for them to be distributable artifacts as we&#x27;d use them in other languages. More like a glorified object file cache. So what problem does it even solve?
        • forrestthewoods5 hours ago
          Because as a percentage of global C++ builds they’re used in probably 0.0001% of builds with no line of sight to that improving.<p>They have effectively zero use outside of hobby projects. I don’t know that any open source C++ library I have ever interacted with even pretends that modules exist.
      • hrmtst938377 hours ago
        &quot;Failed idea&quot; gives modules too much credit. Outside old codebases, almost no one outside C++ diehards have the patience for the build and tooling circuss they create, and if you need fast iteration plus sane integration with existing deps, modules are like trading your shoes for roller skates in a gravel lot. Adopting them now feels like volunteering to do tax forms in assembbly.
    • dheera5 hours ago
      I frankly wish we&#x27;d stop developing C++. It&#x27;s so hard to keep track of all the new unnecessary toys they&#x27;re adding to it. I thought I knew C++ until I read some recent C++ code. That&#x27;s how bad it is.<p>Meanwhile C++ build system is an abomination. Header files should be unnecessary.
      • ranger_danger9 minutes ago
        You don&#x27;t have to keep up with or use any of the new features. I still pay my bills writing C++98 and have no desire to use a higher version.
  • affenape8 hours ago
    Finally, reflection has arrived, five years after I last touched a line in c++. I wonder how long would it take the committee, if ever, to introduce destructing move.
    • IshKebab6 hours ago
      Yeah I feel the same way. Lots of nice features that would have been helpful 5 years ago before I switched to Rust.
  • AyanamiKaine6 hours ago
    I am actually excited for post and pre conditions. I think they are an underused feature in most languages.
  • rr8083 hours ago
    I switched from C++ to Java&#x2F;Python 20 years ago. I never really fit in, I just dont understand when people talk about the complicated frameworks to avoid multithreading&#x2F;mutexes etc when basic C++ multi threading is much simpler than rxjava or async&#x2F;await or whatever is flavor of the month.<p>But C++ projects are usually really boring. I want to go back but glad I left. Has anyone found a place where C++ style programming is in fashion but isn&#x27;t quite C++? I hope that makes sense.
  • chrisaycock6 hours ago
    std::execution is very interesting, but will be difficult to get started with, as cautioned by Sutter. This HPC Wire article demonstrates how to use standard C++ to benefit from asynchronously parallel computation on both CUDA and MPI:<p><a href="https:&#x2F;&#x2F;www.hpcwire.com&#x2F;2022&#x2F;12&#x2F;05&#x2F;new-c-sender-library-enables-portable-asynchrony&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.hpcwire.com&#x2F;2022&#x2F;12&#x2F;05&#x2F;new-c-sender-library-enab...</a><p>Overlapping communication and computation has been a common technique for decades in high-performance computing to &quot;hide latency&quot;, which leads to better scaling. Now standard C++ can be used to express parallel algorithms without tying to a specific scheduler.
  • porise7 hours ago
    I don&#x27;t care until they stop pretending Unicode doesn&#x27;t exist.
    • usrnm6 hours ago
      What are you talking about, there is actually too much unicode awareness in C++. Unicode is not the same thing as utf-8. And, frankly, no language does it right, I&#x27;m not even sure &quot;right&quot; exists with Unicode
      • leni5365 hours ago
        Too much unicode in standard C++? Where?
        • Blackthorn4 hours ago
          c++20&#x27;s u8strings took a giant steaming dump on a number of existing projects, to the point that compiler flags had to be introduced to disable the feature just so c++20 would work with existing codebases. Granted that&#x27;s utf-8 (not the same thing as unicode, as mentioned) but it&#x27;s there.
        • kccqzy2 hours ago
          Things like char32_t, std::u32string for storing UTF-32 characters.
  • levodelellis8 hours ago
    Great. C++20 has been my favorite and I was wasn&#x27;t sure what the standards says since it&#x27;s been a while. I&#x27;ll be reading the C++26 standard soon
  • einpoklum5 hours ago
    If you ask me (and why wouldn&#x27;t you? :-)...) I really wish the C++ WG would do several things:<p>1. Standardize a `restrict` keyword and semantics for it (tricky for struct&#x2F;class fields, but should be done).<p>2. Uniform Function Call Syntax! That is, make the syntax `obj.f(arg)` mean simply `f(obj, arg)` . That would make my life much easier, both as a user of classes and as their author. In my library authoring work particularly. And while we&#x27;re at it, let us us a class&#x27; name as a namespace for static methods, so that Obj::f the static method is simply the method f in namespace Obj.<p>3. Get compiler makers to have an ABI break, so that we can do things like passing wrapped values in registers rather than going through memory. See: <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;58339165&#x2F;1593077" rel="nofollow">https:&#x2F;&#x2F;stackoverflow.com&#x2F;q&#x2F;58339165&#x2F;1593077</a><p>4. Get rid of the current allocators in the standard library, which are type-specific (ridiculous) and return pointers rather than regions of memory. And speaking of memory regions (i.e. with address and size but no element type) - that should be standardized too.
  • VerifiedReports7 hours ago
    As long as programmers still have to deal with header files, all of this is lipstick on a pig.
    • jjmarr6 hours ago
      You don&#x27;t on new projects. CMake + ninja has support for modules on gcc, clang, and MSVC.<p>This should be your default stack on any small-to-medium sized C++ project.<p>Bazel, the default pick for very large codebases, also has support for C++20 modules.
      • VerifiedReports6 hours ago
        Thanks. It&#x27;s been a long time since I started a C++ project, and I&#x27;ve never set up any build chain in Visual Studio or Xcode other than the default.
      • duped2 hours ago
        I have yet to see modules in the wild. What I have seen extensively are header-only projects.
        • FrostKiwi31 minutes ago
          It&#x27;s the fault of built systems. CMake still doesn&#x27;t support `import std` officially and undocumented things are done in the ecosystem [1]<p>But once it works and you setup the new stuff, having started a new CPP26 Project with modules now, it&#x27;s kinda awesome. I&#x27;m certainly never going back. The big compilers are also retroactively adding `import std` to CPP20, so support is widening.<p>[1] <a href="https:&#x2F;&#x2F;gitlab.kitware.com&#x2F;cmake&#x2F;cmake&#x2F;-&#x2F;work_items&#x2F;27706" rel="nofollow">https:&#x2F;&#x2F;gitlab.kitware.com&#x2F;cmake&#x2F;cmake&#x2F;-&#x2F;work_items&#x2F;27706</a>
        • jjmarr1 hour ago
          You&#x27;re not supposed to distribute the precompiled module file. You are supposed to distribute the source code of the module.<p>Header-only projects are the best to convert to modules because you can put the implementation of a module in a &quot;private module fragment&quot; in that same file and make it invisible to users.<p>That prevents the compile-time bloat many header-only dependencies add. It also avoids distributing a `.cpp` file that has to be compiled and linked separately, which is why so many projects are header-only.
          • duped1 hour ago
            What I mean is, I have yet to see projects in the wild _use modules at all_.
      • sgt6 hours ago
        How about using Zig to build C++ projects?
        • jjmarr3 hours ago
          I haven&#x27;t used it.<p>That being said, while it <i>looks</i> better than CMake, for anything professional I need remote execution support to deviate from the industry standard. Zig doesn&#x27;t have that.<p>This is because large C++ projects reach a point where they cannot be compiled locally if they use the full language. e.g. Multi-hour Chromium builds.
  • delduca7 hours ago
    Sadly, transparent hash strings for unordered_map are out.
    • secondcoming6 hours ago
      It is annoying that they didn&#x27;t just apply this to all containers
  • rustyhancock8 hours ago
    I look forwards to getting to make use of this in 2040!<p>Proper reflection is exciting.
    • bigbuppo7 hours ago
      GCC has it marked as &#x27;RESOLVED FIXED&#x27; as of about a week and a half ago. So, it&#x27;s coming.<p>Also, useful: <a href="https:&#x2F;&#x2F;gcc.gnu.org&#x2F;projects&#x2F;cxx-status.html" rel="nofollow">https:&#x2F;&#x2F;gcc.gnu.org&#x2F;projects&#x2F;cxx-status.html</a>
      • rustyhancock6 hours ago
        Support in GCC isn&#x27;t what limits my usage of latest C++ at work.
  • FpUser6 hours ago
    I am curious what is their strategy to get language to the stage where the US government will make it cosher for new projects
    • jandrewrogers5 hours ago
      No such strategy is necessary. That discourse was about not using C++ for applications where Java would work just as well.<p>The US government still uses C++ widely for new projects. For some types of applications it is actually the language of choice and will remain so for the foreseeable future.
      • FpUser5 hours ago
        &gt;&quot;For some types of applications it is actually the language of choice...&quot;<p>Can you give an example please? And how does it correspond to government ONCD report and other government docs &quot;recommending&quot; &quot;safe&quot; languages like: Rust (noted for its ability to prevent memory-unsafe code), Go, Java, Swift, C#, Ruby, Ada<p>Among other things I design and implement high performance C++ backends. for some I got SOCS2 Type II certification but I am curious about future. Do not give a flying fuck about what the criteria for military projects as I would not ever touch one even if given a chance.
        • jandrewrogers2 hours ago
          It is the high-performance&#x2F;high-scale data processing and storage engines for data-intensive applications, some of which are used in high-assurance environments. These are used outside of defense&#x2F;intel (the data models are generic) but defense&#x2F;intel tends to set the development standards for government since theirs are the strictest and most rigorous.<p>An increasingly common requirement is the ability to robustly reject adversarial workloads in addition to being statically correct. Combined with the high-performance&#x2F;high-scale efficiency requirements, this dictates what the software architecture can look like.<p>There are a few practical reasons Rust is not currently considered an ideal fit for this type of development. The required architecture largely disables Rust&#x27;s memory-safety advantages. Modern C++ has significantly better features and capabilities under these constraints, yielding a smaller, more maintainable code base. People worry about supply chain attacks but I don&#x27;t think that is a major factor here.<p>Less obvious, C++ has strong compile-time metaprogramming and execution features that can be used to extensively automate verification of code properties with minimal effort. This allows you to trivially verify many correctness properties of the code that Rust cannot. It ends up being a comparison of unsafe Rust versus verification maximalist C++20, which tilts the safety&#x2F;reliability aspects pretty hard toward C++. Code designed to this standard of reliability has extremely low defect rates regardless of language but it is much easier in some languages than others. I even shipped Python once.<p>A lot of casual C++ code doesn&#x27;t bother with this level of verification, though they really should. It has been possible for years now. More casual applications also have more exposure to memory safety issues but those mostly use Java in my experience, at least in government.
          • portaltonowhere1 hour ago
            &gt; Less obvious, C++ has strong compile-time metaprogramming and execution features that can be used to extensively automate verification of code properties with minimal effort<p>Would you be willing to share some more information about this? Interested in learning more since this sort of thing rarely seems to come up in typical situations I work in.
  • Tenobrus6 hours ago
    &quot;Japanese soldier who kept fighting 29 years after World War 2&quot;
    • cedws5 hours ago
      I watched a talk from Bjarne Stroustrup at CppCon about safety and it was pretty second hand embarrassing watching him try to pretend C++ has always been safe and safety mattered all along to them before Rust came along.
      • einpoklum5 hours ago
        Well, there has been a long campaign against manual memory management - well before Rust was a thing. And along with that, a push for less use of raw pointers, less index loops etc. - all measures which, when adopted, reduce memory safety hazards significantly. Following the Core Guideliness also helps, as does using span&#x27;s. Compiler warnings has improved, as has static analysis, also in a long process preceding Rust.<p>Of course, this is not completely guaranteed safety - but safety has certainly mattered.
        • cedws4 hours ago
          &gt;Following the Core Guideliness also helps<p>Yes, this what Stroustrup said and it makes me laugh. IIRC he phrased with a more of a &#x27;we had safety before Rust&#x27; attitude. It also misses the point, safety shouldn&#x27;t be opt-in or require memorising a rulebook. If safety is that easy in C++ why is everyone still sticking their hand in the shredder?
  • the__alchemist7 hours ago
    [flagged]
    • throwawaypath6 hours ago
      Please don&#x27;t use Hacker News as a religious or ideological battleground. It tramples curiosity. Please don&#x27;t pick the most religiously&#x2F;ideologically provocative thing in an article or post to complain about in the thread. Find something interesting to respond to instead.
      • the__alchemist6 hours ago
        This <i>is</i> interesting! People ignoring this, I think, is also interesting on its own. I respect if other people disagree, but that&#x27;s my 2c. I think our overton windows may not agree here, but I think this is part of the value of discussions with other humans.<p>Are you a moderator? The directive tone of this post is as if from an authority figure, but, but I do not believe you are one.<p>I do not believe there is anything about a religious or ideological background here. Could you please clarify?<p>I also believe it is <i>your</i> post that could be more accurately described as trampling curiosity; I believe there is a role reversal, in that I think <i>your</i> comment is a better description for <i>trampling curiosity</i> than the post your are responding. I&#x27;m not trying to be snarky - I&#x27;m curious how you came to those conclusions.
        • kzrdude6 hours ago
          The tone of the GP is such because it&#x27;s a quote from the rules&#x2F;guidelines. However, applying that rule to what you said makes no sense to me, fwiw.
  • ill_ion6 hours ago
    Contracts feel like the right direction but the wrong execution timeline. The Ada&#x2F;SPARK model shows how powerful contracts become when they feed into static verification — but that took decades of iteration on a language with far cleaner semantics. Bolting that onto C++ where UB is load-bearing infrastructure is a different beast entirely. The real risk isn&#x27;t complexity for complexity&#x27;s sake — it&#x27;s that a &quot;minimum viable&quot; contracts spec gets locked in, and then the things that would actually make it useful for proof assistants become impossible to retrofit because they&#x27;d break the v1 semantics. Bjarne&#x27;s concern about &quot;incomplete&quot; is more worrying to me than &quot;bloated.&quot;
    • sgt6 hours ago
      Nice try, clanker slop