16 comments

  • Night_Thastus7 hours ago
    Nothing particularly notable here. A lot of it seems to be &#x27;We have something in-house designed for our use cases, use that instead of the standard lib equivalent&#x27;.<p>The rest looks very reasonable, like avoiding locale-hell.<p>Some of it is likely options that sand rough edges off of the standard lib, which is reasonable.
    • ryandrake5 hours ago
      &gt; We have something in-house designed for our use cases, use that instead of the standard lib equivalent<p>Yea, you encounter this a lot at companies with very old codebases. Don&#x27;t use &quot;chrono&quot; because we have our own date&#x2F;time types that were made before chrono even existed. Don&#x27;t use standard library containers because we have our own containers that date back to before the STL was even stable.<p>I wonder how many of these (or the Google style guide rules) would make sense for a project starting today from a blank .cpp file. Probably not many of them.
      • LexiMax3 hours ago
        &gt; I wonder how many of these (or the Google style guide rules) would make sense for a project starting today from a blank .cpp file. Probably not many of them.<p>The STL makes you pay for ABI stability no matter if you want it or not. For some use cases this doesn&#x27;t matter, and there are some &quot;proven&quot; parts of the STL that need a lot of justification for substitution, yada yada std::vector and std::string.<p>But it&#x27;s not uncommon to see unordered_map substituted with, say, sparsehash or robin_map, and in C++ libraries creating interfaces that allow for API-compatible alternatives to use of the STL is considered polite, if not necessarily ubiquitous.
      • mtklein5 hours ago
        ... and for many of those blank .cpp file projects, the style guide should probably just read &quot;start a blank .rs file instead.&quot;
        • acdha4 hours ago
          Look, I even share your language preference but this is still unnecessary.
          • galangalalgol3 hours ago
            Are there really any good reasons to start a brand new project in c++ though? No one who can write modern c++ has any trouble with rust in my experience, and all the other common options are even quicker to pick up. Creating bindings isn&#x27;t hard anymore if your niche library doesn&#x27;t have any yet. Syntactic preference I guess, but neither c++ or rust are generally considered elegant or aesthetic choices.
            • cpgxiii2 hours ago
              Because &quot;brand new&quot; doesn&#x27;t mean devoid of context. Within your domain, there will still be common libraries, interfaces, and tools.<p>C++ is very flexible, with a lot of very mature tooling and incredibly broad platform support. If you&#x27;re writing some web server to run on the hardware of your choosing, then sure, that doesn&#x27;t matter. But if you&#x27;re writing something deeply integrated with platform&#x2F;OS interfaces, or graphics, or needs to support some less common platforms, then C++ is often your only practical option for combining expressiveness and performance.
              • galangalalgol32 minutes ago
                This is the sort of info I was trolling for, but what are those platforms and os? Targets llvm doesn&#x27;t handle yeah c++ makes sense, or c. A sibling mentions xcode, which makes sense. Graphics seems questionable, vulkan support is fine. Windows support has seemed finetoo, the same gui has worked as what we wrote for Linux.
            • bigstrat20031 hour ago
              Maybe, maybe not. But either way it&#x27;s just plain rude to charge into a C++ thread to drop a comment saying how the language sucks and you should use (insert other language) instead.
            • kstenerud2 hours ago
              Yes. If you&#x27;re targeting Apple platforms and want to allow clients to use your product in Xcode (the common case) or even need Swift&#x2F;ObjC interop yourself, using rust or anything not explicitly supported by Apple and Xcode is just too fiddly.
              • galangalalgol41 minutes ago
                Why not pick swift in this situation over c++?
            • BearOso3 hours ago
              Rust becomes a significant burden if you need a GUI or hardware-accelerated graphics.
            • CamperBob22 hours ago
              (Shrug) If I want Rust, I&#x27;ll feed my C++ to an LLM and tell it to port it to Rust. Since we&#x27;ve been assured that Rust magically fixes everything that&#x27;s wrong, bad, or unsafe about C++, this seems like a sound approach.
              • galangalalgol43 minutes ago
                We probably aren&#x27;t that far off actually. Even taking asm with no symbols back into rust works well. You have truth, just have the agent repeat until the asm matches. Doesn&#x27;t work on giant codebases, but on a few functions it absolutely does. And while the llm may get the algorithm wrong, the type system does seem to help it generate useful code in rust for a starting place v
    • vitaut5 hours ago
      Somewhat notable is that `char8_t` is banned with very reasonable motivation that applies to most codebases:<p>&gt; Use char and unprefixed character literals. Non-UTF-8 encodings are rare enough in Chromium that the value of distinguishing them at the type level is low, and char8_t* is not interconvertible with char* (what ~all Chromium, STL, and platform-specific APIs use), so using u8 prefixes would obligate us to insert casts everywhere. If you want to declare at a type level that a block of data is string-like and not an arbitrary binary blob, prefer std::string[_view] over char*.
      • ChrisSD5 hours ago
        `char8_t` is probably one of the more baffling blunders of the standards committee.
        • jjmarr4 hours ago
          there is no guarantee `char` is 8 bits, nor that it represents text, or even a particular encoding.<p>If your codebase has those guarantees, go ahead and use it.
          • 20k4 hours ago
            char8_t also isn&#x27;t guaranteed to be 8-bits, because sizeof(char) == 1 and sizeof(char8_t) &gt;= 1. On a platform where char is 16 bits, char8_t will be 16 bits as well<p>The cpp standard explicitly says that it has the same size, typed, signedness and alignment as unsigned char, but its a distinct type. So its pretty useless, and badly named
          • dataflow4 hours ago
            How many non-8-bit-char platforms are there with char8_t support, and how many do we expect in the future?
            • RobotToaster3 hours ago
              Mostly DSPs
              • dataflow2 hours ago
                Non-8-bit-char DSPs would have char8_t support? Definitely not something I expected, links would be cool.
          • Maxatar1 hour ago
            There&#x27;s no guarantee char8_t is 8 bits either, it&#x27;s only guaranteed to be at least 8 bits.
    • zeroq2 hours ago
      Not an Googler, but my, probably way too much romanticized, understanding of Google was that they never ask you about specific tech because for everything there&#x27;s an in-house version.<p>The problem is that too many people drank too much koolaid and trying to parrot everything to a letter without understanding the bigger picture.<p>The best example would be Kubernetes. Employed by many orgs that have 20 devs and 50 services.
  • bengoodger4 hours ago
    Seeing the comments here talking about ancient codebases got me wistful for when Chromium was new and everything seemed possible.<p>That triggered a flash of feeling extremely old realizing we broke ground on this codebase 20 years ago this year!
  • dnmc6 hours ago
    There are yet more interesting docs in the parent directory :)<p><a href="https:&#x2F;&#x2F;chromium.googlesource.com&#x2F;chromium&#x2F;src&#x2F;+&#x2F;main&#x2F;styleguide&#x2F;c++" rel="nofollow">https:&#x2F;&#x2F;chromium.googlesource.com&#x2F;chromium&#x2F;src&#x2F;+&#x2F;main&#x2F;styleg...</a>
  • ddtaylor7 hours ago
    Exceptions are banned, but an exception is made for Windows.
    • refulgentis7 hours ago
      grep&#x27;d &quot;exception&quot; and &quot;Windows&quot;, tl;dr only Windows reference is for `[[no_unique_address]]`. Therefore I am probably missing a joke :)
      • jesse__7 hours ago
        Might be referring to SEH ..? Just a wild guess
        • refulgentis6 hours ago
          Ah, found it: in the style guide linked from this article. <a href="https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html#Exceptions" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html#Exceptions</a>
  • lateforwork5 hours ago
    You almost never see a list of banned Java features (or even banned C# features). On the other hand any serious C++ development team is going to have a list of banned features. Java eliminated the features that you would want to ban.
    • nilamo5 hours ago
      This seems factually incorrect and ignorant of history. Java has tons of things which shouldn&#x27;t be used. Serialization (use Jackson now, not the built-in stuff), date&#x2F;time (there&#x27;s an entirely different namespace so you don&#x27;t accidentally use garbage classes), etc.<p>C# similarly has old warts that are discouraged now. .NET Framework is a great example (completely different from modern c#, which used to be called &quot;dotnet core&quot;). WPF and MAUI are also examples. Or when &quot;dynamic&quot; was used as a type escape hatch before the type system advanced to not need it. ASP being incompatible with ASP.NET, the list goes on.<p>They&#x27;re just languages, there&#x27;s no reason to pretend they&#x27;re perfect.
      • twisteriffic4 hours ago
        &gt; C# similarly has old warts that are discouraged now. .NET Framework is a great example (completely different from modern c#, which used to be called &quot;dotnet core&quot;). WPF and MAUI are also examples. Or when &quot;dynamic&quot; was used as a type escape hatch before the type system advanced to not need it. ASP being incompatible with ASP.NET, the list goes on.<p>Almost all of this is incorrect or comparing apples to oranges.<p>.net framework and .net core are runtime and standard library impl, not languages. C# is a language that can target either runtime or both. Framework is still supported today, and you can still use most modern C# language features in a project targeting it. WPF and Maui are both still supported and widely used. ASP predates .net - c# was never a supported language in it. ASP.net core has largely replaced ASP.net, but it&#x27;s again a library and framework, not a language feature.<p>Dynamic in c# and the dlr are definitely not widely used because it&#x27;s both difficult to use safely and doesn&#x27;t fit well with the dominant paradigm of the language. If you&#x27;re looking for STD lib warts binaryserializer would have been an excellent example.
      • lateforwork4 hours ago
        Those are libraries not language features.
        • plorkyeran4 hours ago
          So is nearly all of this list.
          • lateforwork4 hours ago
            There are clearly demarcated language features sections and library sections. That definitely makes sense for C++, it is a poorly designed language and you definitely have to know what features to avoid.
        • bathtub3654 hours ago
          dynamic is a language feature
    • oldmanhorton3 hours ago
      In C#, you would normally implement rules like this with a custom Roslyn Analyzer or with <a href="https:&#x2F;&#x2F;github.com&#x2F;dotnet&#x2F;roslyn&#x2F;blob&#x2F;main&#x2F;src&#x2F;RoslynAnalyzers&#x2F;Microsoft.CodeAnalysis.BannedApiAnalyzers&#x2F;BannedApiAnalyzers.Help.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dotnet&#x2F;roslyn&#x2F;blob&#x2F;main&#x2F;src&#x2F;RoslynAnalyze...</a>. It’s fair to say C# projects tend to have smaller denylists than mature C++ projects, but banned APIs definitely exist in mature C# projects.
    • AdieuToLogic4 hours ago
      &gt; You almost never see a list of banned Java features ...<p>The instanceof[0] operator is typically banned from use in application code and often frowned upon in library implementations.<p>0 - <a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;specs&#x2F;jls&#x2F;se7&#x2F;html&#x2F;jls-15.html#jls-15.20.2" rel="nofollow">https:&#x2F;&#x2F;docs.oracle.com&#x2F;javase&#x2F;specs&#x2F;jls&#x2F;se7&#x2F;html&#x2F;jls-15.htm...</a>
      • twic4 hours ago
        I&#x27;ve never heard of that being banned. It hasn&#x27;t been banned anywhere i&#x27;ve written Java.
    • MBCook4 hours ago
      As a Java programmer I can only think of one thing:<p>Reflection - unless you really need to do something fancy almost certainly a very bad idea in normal application code.<p>Other than that it’s either just limiting yourself to a specific JVM version or telling people not to use old syntax&#x2F;patterns that were replaced with better options long ago.
    • jameslars4 hours ago
      I think Java has plenty of features that end up implicitly banned at least. e.g. you will really never see a `java.util.Vector` in any modern code base. No one `implements Serializable` anymore in practice. `Objects.equals()` and `Objects.hashCode()` get you through 99% of equals&#x2F;hash code implementations. The list goes on.<p>I guess the difference is it&#x27;s rarely &quot;dangerous&quot; or &quot;hard to reason about&quot; using the old features unlike what I see in the C++ list. Java replaces things with better things and momentum shifts behind them kind of naturally because the better things are objectively better.
    • madeofpalk4 hours ago
      I would imagine most codebases, even in modern languages, tend to have a list of banned features. Typically you use a linter to catch these.
  • Tempest19816 hours ago
    Where does it list the preferred alternatives to banned features?<p>For example:<p>&gt; The &lt;filesystem&gt; header, which does not have sufficient support for testing, and suffers from inherent security vulnerabilities.
    • comex5 hours ago
      For most of the banned library features, the preferred alternative is listed right there in the notes. &lt;filesystem&gt; is one of the exceptions.
    • jeffbee6 hours ago
      base&#x2F;files
    • TheRealPomax6 hours ago
      Gonna venture a guess and say probably <a href="https:&#x2F;&#x2F;www.chromium.org&#x2F;developers" rel="nofollow">https:&#x2F;&#x2F;www.chromium.org&#x2F;developers</a>, as that&#x27;s where all the information for folks who actually need to know that kind of thing lives.
  • dfajgljsldkjag7 hours ago
    The banned list proves that context matters more than having the newest tools. These features work well for small apps but they cause problems in a project this size.
    • trinix9125 hours ago
      IIRC a big part of Google’s coding guidelines is also about making it easy for people not heavily invested in a specific language to contribute safely. So not necessarily a project size but rather an organizational concern.<p>They’d rather see it done the same way it would’ve been in any other similar language than with a language specific feature.<p>There are also portability concerns in mind given that projects like Chromium have to be easily portable across a vast amount of platforms (this shows with things like long long which is also on the list).
      • jonstewart4 hours ago
        Go is an extremely cynical language in this regard.
    • diabllicseagull55 minutes ago
      Agreed. I also prefer conformity over sporadic use of new features going against an already set of standards in a codebase. it&#x27;s overall less cognitive load on whoever is reading it imho.
    • loeg5 hours ago
      Some of it is historical reasons or portability more than anything else. Chrome is an old C++ project and evolved many of its own versions of functionality before standardization; and there&#x27;s benefit to staying on its own implementations rather than switching.
  • amelius6 hours ago
    Is there a way to make this formal, like in the code, making the compiler complain when you try to use these features?
    • 6r175 hours ago
      I&#x27;m not a c++ user but i&#x27;m pretty sure you should be able to pull-off a macro to do that ; in c you could alias the lib for something that breaks + alert ; I don&#x27;t know how I would integrate such additional compiler checks in rust for other kinds of rules however - it&#x27;s interesting to think about
    • loeg5 hours ago
      It is relatively easy to check these things with static analyzers, if nothing else.
    • TingPing5 hours ago
      It’s a bit different, but WebKit uses Clangs static analysis.
    • mkoubaa4 hours ago
      Kythe can be used for that
  • weinzierl4 hours ago
    I&#x27;d curious about the banned Rust features. Surely, Rust has at lot fewer foot guns, but it isn&#x27;t that there aren&#x27;t <i>any</i>.
    • jtrueb4 hours ago
      Heard of `#![forbid(unsafe_code)]` ?
      • weinzierl59 minutes ago
        I doubt unsafe would be blatantly banned. I was more thinking of things like glob imports.
  • bfrog3 hours ago
    This list is longer than the features in all of C I feel like at first glance. Wow that is overwhelming.
  • kazinator4 hours ago
    Good call on those u8&quot;...&quot; literals.<p>Source code should all be UTF-8 natively, letting you directly write UTF-8 text between quotes.<p>Exactly their rationale.<p>These literals are a solution in search of a problem ... which is real but has a much better solution.
  • jesse__7 hours ago
    It&#x27;s remarkable to me how many codebases ban exceptions and yet, somehow, people still insist they&#x27;re good.
    • BeetleB7 hours ago
      &gt; Our advice against using exceptions is not predicated on philosophical or moral grounds, but practical ones. ... Things would probably be different if we had to do it all over again from scratch.<p>They are clearly not against them <i>per se</i>. It simply wasn&#x27;t practical for them to include it into their codebase.<p>And I think a lot of the cons of exceptions are handled in languages like F#, etc. If f calls g which calls h, and h throws an exception, the compiler will require you to deal with it somehow in g (either handle or explicitly propagate).
      • jesse__7 hours ago
        My issue with exceptions is also practical. If they didn&#x27;t introduce significant stability issues, I&#x27;d have no problem. As it stands, it&#x27;s impossible to write robust software that makes use of C++ exceptions.<p>&gt; the compiler will require you to deal with it somehow in g<p>I agree, this is the sensible solution.
        • yunnpp5 hours ago
          What stability issues?
          • rauli_2 hours ago
            Unchecked exceptions will eventually lead into programs crashing because some developer forgot to catch specific type of exception somewhere.
      • jandrewrogers6 hours ago
        In low-level systems software, which is a primary use case for C++, exceptions can introduce nasty edge cases that are difficult to detect and reason about. The benefits are too small to justify the costs to reliability, robustness, and maintainability.<p>Exceptions in high-level languages avoid many of these issues by virtue of being much further away from the metal. It is a mis-feature for a systems language. C++ was originally used for a lot of high-level application code where exceptions might make sense that you would never use C++ for today.
        • drnick15 hours ago
          &gt; In low-level systems software, which is a primary use case for C++<p>I don&#x27;t this this is true. There is A LOT of C++ for GUI applications, video games, all kind of utilities, scientific computing and others. In fact, I find that the transition to &quot;modern&quot; alternatives from native GUI toolkits in C&#x2F;C++ has led to a regression in UI performance in general. Desktop programs performed better 20 years ago when everything was written in Win32, Qt, GTK and others and people did not rely on bloated Web toolkits for desktop development. Even today you can really feel how much more snappy and robust &quot;old school&quot; programs are relative to Electron and whatnot.
          • saghm5 hours ago
            To clarify, you think that low-level systems software is only a secondary use case for C++? The part you quoted does not make claims about whether there are other primary use cases, just that low-level systems software is one of them, so it&#x27;s not clear why it being useful elsewhere is a rebuttal of that.
        • BeetleB6 hours ago
          &gt; In low-level systems software, which is a primary use case for C++<p>I can assure you: Most C++ SW is not written for low-level.<p>&gt; exceptions can introduce nasty edge cases that are difficult to detect and reason about.<p>That&#x27;s true, except for languages that ensure you can&#x27;t simply forget that something deep down the stack can throw an exception.<p>BTW, I&#x27;m not saying C++&#x27;s exceptions are in any way good. My point is that exceptions are bad <i>in C++</i>, and not necessarily bad in general.
          • beached_whale6 hours ago
            The model of communicating errors with exceptions is really nice. The implementation in C++ ABI&#x27;s is not done as well as it could be and that results in large sad path perf loss.
          • jandrewrogers5 hours ago
            &gt; That&#x27;s true, except for languages that ensure you can&#x27;t simply forget that something deep down the stack can throw an exception.<p>Sometimes it is not safe to unwind the stack. The language is not relevant. Not everything that touches your address space is your code or your process.<p>Exception handlers must have logic and infrastructure to detect these unsafe conditions and then rewrite the control flow to avoid the unsafety. This both adds overhead to the non-exceptional happy path and makes the code flow significantly uglier.<p>The underlying cause still exists when you don&#x27;t use exceptions but the code for reasoning about it is highly localized and usually has no overhead because you already have the necessary context to deal with it cleanly.
            • le-mark2 hours ago
              &gt; Sometimes it is not safe to unwind the stack.<p>This where garbage collected languages shine.
        • kllrnohj6 hours ago
          If you forget to handle a C++ exception you get a clean crash. If you forget to handle a C error return you get undefined behavior and probably an exploit.<p>Exceptions are <i>more robust</i>, not less.
          • nomel6 hours ago
            Yeap. forgetting to propagate or handle an error provided in a return value is very very easy. If you fail to handle an exception, you halt.
            • vasilvv1 hour ago
              For what it&#x27;s worth, C++17 added [[nodiscard]] to address this issue.
        • beached_whale6 hours ago
          C++ exceptions are fast for happy path and ABI locked for sad path. They could be much faster than they are currently. Khalil Estell did a few talks&#x2F;bunch of work on the topic and saw great improvements. <a href="https:&#x2F;&#x2F;youtu.be&#x2F;LorcxyJ9zr4" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;LorcxyJ9zr4</a>
          • beached_whale1 hour ago
            Oops, I meant they are ABI locked so sad path cannot be fixed.
        • senfiaj6 hours ago
          &gt; &quot;In low-level systems software, which is a primary use case for C++, exceptions can introduce nasty edge cases that are difficult to detect and reason about. The benefits are too small to justify the costs to reliability, robustness, and maintainability.&quot;<p>Interestingly, Microsoft C &#x2F; C++ compiler does support structured exception handling (SEH). It&#x27;s used even in NT kernel and drivers. I&#x27;m not saying it&#x27;s the same thing as C++ exceptions, since it&#x27;s designed primarily for handling hardware faults and is simplified, but still shares some core principles (guarded region, stack unwinding, etc). So a limited version of exception handling can work fine even in a thing like an OS kernel.
          • jandrewrogers5 hours ago
            FWIW, I think it is possible to make exception-like error handling work. A lot of systems code has infrastructure that looks like an exception handling framework if you squint.<p>There are two main limitations. Currently, the compiler has no idea what can be safely unwound. You could likely annotate objects to provide this information. Second, there is currently no way to tell the compiler what to do with an object in the call stack may not be unwound safely.<p>A lot of error handling code in C++ systems code essentially provides this but C++ exceptions can&#x27;t use any of this information so it is applied manually.
        • matheusmoreira6 hours ago
          Exceptions are actually a form of code compression. Past some break even point they are a net benefit, even in embedded codebases. They&#x27;re &quot;bad&quot; because the C++ implementation is garbage but it turns out it&#x27;s possible to hack it into a much better shape:<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;LorcxyJ9zr4" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;LorcxyJ9zr4</a>
          • secondcoming6 hours ago
            There is no such thing as the &#x27;C++ implementation&#x27; of exceptions. Each vendor can do it differently.
      • jayd166 hours ago
        Is this correct? I don&#x27;t know F# but I thought it had unchecked exceptions. How does it handle using C# libs that throw unchecked exceptions?
        • BeetleB6 hours ago
          My memory of F# is very rusty, but IIRC, there are two types of error handling mechanisms. One of them is to be compatible with C#, and the other is fully checked.
          • lateforwork5 hours ago
            Unchecked exceptions is a design flaw of C# see here: <a href="https:&#x2F;&#x2F;mckoder.medium.com&#x2F;the-achilles-heel-of-c-why-its-exception-handling-falls-short-f7f932488aba" rel="nofollow">https:&#x2F;&#x2F;mckoder.medium.com&#x2F;the-achilles-heel-of-c-why-its-ex...</a>
      • heyitsdaad6 hours ago
        The “pros” list is exceptionally weak. This was clearly written by someone who doesn’t like exceptions. Can’t blame them.
    • azov6 hours ago
      Most codebases that ban exceptions do it because they parrot Google.<p>Google’s reasons for banning exceptions are historical, not technical. Sadly, this decision got enshrined in Google C++ Style Guide. The guide is otherwise pretty decent and is used by a lot of projects, but this particular part is IMO a disservice to the larger C++ ecosystem.
      • alextingle6 hours ago
        I agree. I&#x27;ve worked on large C++ code bases that use exceptions, and they&#x27;ve never caused us any real problems.
    • ryandrake6 hours ago
      I think reasonable people can disagree about whether C++ exceptions are &quot;good&quot; or not.<p>There are things you can&#x27;t do easily in C++ without using exceptions, like handling errors that happen in a constructor and handling when `new` cannot alloc memory. Plus, a lot of the standard library relies on exceptions. And of course there&#x27;s the stylistic argument of clearly separating error-handling from the happy-path logic.<p>I won&#x27;t argue that it&#x27;s popular to ban them, though. And often for good reasons.
      • canucker20164 hours ago
        For exception-less C++, you&#x27;d declare an operator new() that doesn&#x27;t throw exceptions and just returns NULL on allocation failure along with a simple constructor and a followup explicitly-called init() method that does the real work which might fail and returns an error value on failure.
    • tester7567 hours ago
      They&#x27;re good for exceptional situations where foundamental, core assumptions are broken for some reason.<p>In such scenario there&#x27;s no error recovery, software is expected to shutdown and raise loud error.
      • jesse__7 hours ago
        If you&#x27;re planning on shutting down, what&#x27;s the fundamental difference between throwing an exception, vs simply complaining loudly and calling exit() ..?
        • trinix9126 hours ago
          Sometimes it’s useful to handle the exception somewhere near its origin so you can close related resources, lockfiles, etc. without needing a VB6 style “On Error GoTo X” global error handler that has to account for all different contexts under which the exceptional situation might have occurred.
          • PhilipRoman6 hours ago
            Your process can crash or be killed at any moment anyway. Depending on in-band cleanup is not reliable.
            • nomel6 hours ago
              Sure, but there are many cases where you don&#x27;t have to halt because you can cleanup and carry on.
          • matheusmoreira6 hours ago
            &gt; a VB6 style “On Error GoTo X” global error handler that has to account for all different contexts under which the exceptional situation might have occurred<p>... That seems like a pretty accurate description of how exception handling mechanisms are implemented under the hood. :)
        • einpoklum5 hours ago
          The code that&#x27;s throwing an exception typically does not know that the exception catcher will shut anything down.<p>And - very often, you would _not_ shut down. Examples:<p>* Failure&#x2F;error in an individual operation or action does not invalidate all others in the set of stuff to be done.<p>* Failure&#x2F;error regarding the interaction with one user does not mean the interaction with other users also has to fail.<p>* Some things can be retried after failing, and may succeed later: I&#x2F;O; things involving resource use, etc.<p>* Some actions have more than one way to perform them, with the calling code not being able to know apriori whether all of them are appropriate. So, it tries one of them, if it fails tries another etc.
      • spacechild15 hours ago
        &gt; They&#x27;re good for exceptional situations where foundamental, core assumptions are broken for some reason.<p>No, that&#x27;s what assertions or contracts are for.<p>Most exceptions are supposed to be <i>handled</i>. The alternative to exceptions in C++ are error codes and `std::expected::. They are used for errors that are <i>expected</i> to happen (even if they may be exceptional). You just shouldn&#x27;t use exceptions for control flow. (I&#x27;m looking at you, Python :)
      • ljm6 hours ago
        Yet, if you can only explain an exception using the word ‘exception’ you’re not making any head way.<p>I like the idea of an exception as a way to blow out of the current context in order for something else to catch it and handle in a generic manner. I don’t like the idea of an exception to hide errors or for conditional logic because you have to know what is handling it all. Much easier to handle it there and then, or use a type safe equivalent (like a maybe or either monad) or just blow that shit up as soon as you can’t recover from the unexpected.
      • dijit7 hours ago
        I use asserts for this purpose.
    • wvenable7 hours ago
      Looking at this ban list, they&#x27;ve removed everything from C++ that makes it fun. Come on people, who doesn&#x27;t love a little std::function?!?<p>On banning exceptions:&quot;Things would probably be different if we had to do it all over again from scratch.&quot;<p><a href="https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html#Exceptions" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html#Exceptions</a>
  • nixosbestos3 hours ago
    Rust is too complicated!!11 Ooops wrong thread.
  • einpoklum5 hours ago
    Since Chromium stopped allowing manifest-v2 extensions, i.e. significantly crippled what extensions can do and made it impossible to use some key extensions like uBlock Origin, I&#x27;ve decided to avoid it.<p>Anyway, about these C++ conventions - to each software house its own I guess. I don&#x27;t think banning exceptions altogether is appropriate; and I don&#x27;t see the great benefit of using abseil (but feel free to convince me it&#x27;s really that good.)
    • jsheard4 hours ago
      If nothing else Abseil gives you state-of-the-art hashmaps that run circles around the STL ones, which are slow pretty much by definition. The spec precludes the modern ways of implementing them.
  • WalterBright6 hours ago
    Modules are banned - they should have just copied D modules.
  • grougnax5 hours ago
    C++ itself should be forever banned