22 comments

  • PaulDavisThe1st6 hours ago
    You can take<p><pre><code> for (auto const &amp; ess : esses) { ... } </code></pre> from my cold dead hands.<p>Also, you can fight me if you want to take<p><pre><code> dynamic_cast&lt;Derived&gt; (base_ptr) </code></pre> and force me to implement my own typing system every time I need to upcast.<p>Basically, stick with C and leave C++ programmers alone. I haven&#x27;t seen a less useful article about C++ in a long time, and as an HN reader, that&#x27;s really saying something.
    • rfgplk6 hours ago
      One thing I&#x27;ve noticed about a lot of these &quot;strict C&quot; developers is that quite often they actually refuse to learn C++. One of the most common complaints of C developers regarding C++ is &quot;it does things behind the scenes&#x2F;performs magic&quot;, often with regards to operator overloading. When they refuse to actually look at the implementation (y&#x27;know you can check if an operator has been overloaded) AND they refuse to acknowledge that a huge chunk of &quot;pure C&quot; does HEAPS of magic behind the scenes (that the developer has no idea about) unless they&#x27;ve actually studied the spec in detail. Malloc and memory allocation methods are at least 10k+ lines of code for instance.
      • fasterik24 minutes ago
        I don&#x27;t think &quot;refusing to learn C++&quot; is the right way to frame it. I want to use the language features that are actually useful to me, without being forced into a specific programming style. I can&#x27;t speak for every &quot;orthodox C++&quot; programmer, but for me that means using exclusively plain-old-data structs, non-member functions, and &quot;dumb&quot; pointers. I have no issue with learning to use a C++ feature when it&#x27;s directly useful to a problem I&#x27;m trying to solve.<p>As one example, I recently found templated lambdas useful in making animations.<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=cw-h0dePYZM" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=cw-h0dePYZM</a>
      • uecker1 hour ago
        I was programming in C++ before switching to C and I would say that C++ adds a huge amount of mental load compared to C. I think one can understand how much of a relieve it is to not worry about everything C++ does only after not using C++ for a quite a while.
      • lelanthran16 minutes ago
        All the foot guns in C are still in C++, and C++ adds a significant multiple more.
      • nuc1e0n17 minutes ago
        c memory allocation functions can be implemented in 1000 lines or so. I&#x27;ve done it myself. Maybe more are needed to handle strange operating systems or architectures, as glib does.
      • lelele5 hours ago
        &gt; y&#x27;know you can check if an operator has been overloaded<p>And there lies the problem with C++: to be sure, you have to check. C++ code can&#x27;t be taken at face value -- the most innocuous-looking code could be a ticking bomb.
        • WalterBright0 minutes ago
          My favorite was the regex engine that was implemented using C++ operator overloading. The author was very proud of it, but you could not tell what code was regex code and what code was math code.<p>I went to some lengths with D to discourage such abusive operating overloading practice.
        • pjmlp5 hours ago
          Just like any C function without looking into the translation unit, don&#x27;t say you blindly believe on the function name.
          • lelele3 hours ago
            Not really. C++ is on another level altogether: the code could be calling implicit conversion operators, the compiler could have instantiated some template code in an unforeseen way, and so on.<p>Years ago, I was really proficient in C++, but after a year of programming in C#, I realized that not once had the behavior of my code caught me off guard. In the following years, I only ran into quirky behavior a couple of times. I could finally program without the constant mental overhead of watching out for C++ pitfalls.
            • pjmlp3 hours ago
              I suppose you&#x27;re aware C# also has implicit conversion operators, operator overloading, reflection, aspect oriented programming, compiler plugins, interceptors.<p>Seems strange to talk down C++ while praising C#, which incidentally has been getting features to increase its use where Microsoft previously might have used C++ instead.<p>You catch pitfalls in any language the same way, using static analysis, which C authors introduced right in 1979, acknowledging the issues with language, which they decided to outsource to another tool, instead of improving the language.<p>A long tradition in computing.
              • lelele2 hours ago
                Yes, C# is becoming more and more complex, but IMO C++ is still in a class of its own. Just compare how many different, sometimes competing ways there are to initialize variables in C++, each with its own subtleties.<p>I guess we&#x27;ll have to agree to disagree here. And of course, even if C++&#x27;s user base seems to be shrinking, it still works well for some categories of programmers.
                • pjmlp1 hour ago
                  Even if it is shrinking, people leaving C++ aren&#x27;t racing to go back to C, rather to languages with similar expressive type systems.<p>Swift, C#, Kotlin, Scala, Rust, Typescript, Python...
        • rfgplk5 hours ago
          But isn&#x27;t this a problem with all code? Looking at a Rust function signature how can you be sure that it does what it says it does? Or python?
          • lelele3 hours ago
            See my reply to a similar objection: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48520416">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48520416</a>
        • LoganDark5 hours ago
          &gt; C++ code can&#x27;t be taken at face value -- the most innocuous-looking code could be a ticking bomb.<p>You can&#x27;t take C code at face value either. The name of a method or type doesn&#x27;t tell you what it does. It could longjmp for all you know.
          • lelele3 hours ago
            See my reply to a similar objection: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48520416">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=48520416</a>
      • 011000116 hours ago
        A lot of us are too busy solving problems. Learning about the latest language features, which we often won&#x27;t be able to use anyway due to the trouble of moving a large dev environment to a newer standard, feels like academic masturbation.<p>C++ folks are very much into their language, and can&#x27;t seem to understand that most folks don&#x27;t want to dedicate significant amounts of mental resources purely to language details.
        • bluGill5 hours ago
          Moving to new C++ is a non event, change the compiler &#x2F; flags and done. Using the new features requires some learning but not a big deal since you can figure out what you need from a summary and learn what is useful for your problem.<p>The problems of the code I&#x27;m writing far exceeds the complexity of the language. Your complaint about complexity fall flat to me, unless you are working on a trivial program you need to deal with things far more complex than any language.
        • pjmlp5 hours ago
          Like implementing the compilers used by C devs.
          • uecker1 hour ago
            GCC was implemented in C and there are plenty of other C compilers written in C. GCC has been converted to C++ at some point, but large parts are still essentially C and I do not think the change to C++ was actually helpful (but others may disagree). In any case, the idea that one needs C++ to have C compilers is certainly simply wrong.
            • delta_p_delta_x1 hour ago
              Clang&#x2F;LLVM with its more permissive licence sees _much_ wider use and is written purely in C++. PlayStation, automotive, platforms and runtimes like Chromium&#x2F;V8, Android, etc. are all built with Clang.
              • lelanthran18 minutes ago
                Clang usage is a fraction of GCC usage.<p>Regards, an embedded dev.
              • uecker59 minutes ago
                How is this relevant? (also wider use for C I would doubt)
            • pjmlp1 hour ago
              Naturally GCC was originally written in C, given its age, and the original GNU coding standards document.<p>With time, the GCC developers acknowledged the benefits of using C++ over C, and migrated the code.<p>GCC requires a C++ compiler to bootstrap since around 2012, and GNU coding standards has been updated to several languages beyond C, time to go up with times.
              • uecker57 minutes ago
                I think the fallacy of this argument is obvious.
      • EPWN3D3 hours ago
        C programmers aren&#x27;t complaining about the &quot;magic&quot; being tens of thousands of lines of code. They&#x27;re complaining about the magic including bizarre side effects that brazenly violate the principle of least astonishment.<p>In C++, you can overload the comma operator to do shit. I&#x27;ve seen it done. There&#x27;s no reason to do it, and no reasonable person would ever expect it in a code base they&#x27;re unfamiliar with. To find bug in that ultimately roots back to that implementation, you have to go eliminate every other whack-job possibility before it even occurs to you that maybe the weirdo who wrote this code chose to overload the comma operator.<p>I&#x27;m not going to argue with anyone who wants to use C++ in their own projects, you do you. But let&#x27;s be real about what C programmers are complaining about. It&#x27;s not line count. It&#x27;s syntactic obfuscation. I don&#x27;t just level this criticism at C++ either. Basically every major new language has its own byzantine syntactic constructs to some degree.
      • jstimpfle5 hours ago
        Trust me, I know more C++ than most or all of my peers (working two jobs simultaneously), and I know a million ways that C++ features suck. Also standard library and containers. If you want I&#x27;ll point out the ways in which std::deque, and even std::map, std::unordered_map, even std::vector (!) suck. IMO, just don&#x27;t do it.
        • stinos2 hours ago
          <i>and even std::map, std::unordered_map, even std::vector (!) suck</i><p>It&#x27;s really hard to take your comment serious because of generalization like this. Maybe they&#x27;re not usable for your particular usecase but that doesn&#x27;t mean they suck. Just like there&#x27;s a &#x27;million&#x27; ways that C++ sucks in your book, there&#x27;s a reason there&#x27;s millions of lines of code out there where these containers are valid usecases and hence work without issues whatsoever nor a need to replace them with something else.
          • jcranmer2 hours ago
            std::map and std::unordered_map are just unbelievably shitty implementations. The former is a red-black tree, which in my entire programming career I have needed to reach for like... twice? It&#x27;s just not the right container for almost any problem you have, yet it&#x27;s the one that gets the short, sweet name. The latter is a bucket-based hashmap, which is about the worst kind of hashmap that can be built. On top of that, their APIs are also really annoying to use compared to, say, Python or Rust&#x27;s implementation. At least C++20 finally added a simple contains method, but something like setdefault is just a chore to get implemented.
          • jstimpfle2 hours ago
            They&#x27;re not useable for anything serious, i.e. high throughput, low frequency, massively concurrent work. In other words, most of the things for which you shouldn&#x27;t better have chosen a different language in the first place.<p>They&#x27;re also unusable by the way because of ergonomic and software architecture factors, such as bad modularity, terrible compile times, unreadable error messages, unreadable symbol names...<p>Yes that is overgeneralizing a little bit but it&#x27;s largely true.<p>The problem is typically not the containers themselves but all the other bad decisions that they push you to make in order to work around their &quot;small issues&quot;.<p>The huge problem is that these containers can get you started quickly, i.e. leetcode type stuff and single threaded stuff, but at some point you&#x27;ll realize your architecture ended up completely in the wrong place because of that.<p>If you haven&#x27;t been thinking deeply about memory management and concurrency, you won&#x27;t be able to understand, no offense meant. I&#x27;ve just fixed another subsystem that was completely overwhelmed, seeing 8x bandwidth gains already on a small testsystem, but the factor is basically unbounded when moving to bigger systems, when it&#x27;s about contended vs uncontended.
            • delta_p_delta_x2 hours ago
              &gt; anything serious, i.e. high throughput, low frequency, massively concurrent work<p>Why is only &#x27;high throughput, low frequency, massively concurrent work&#x27; considered &#x27;serious&#x27;?
              • jstimpfle56 minutes ago
                You are free to make your own definition, what are your suggestions?
              • miroljub9 minutes ago
                Because if you don&#x27;t need any of these, any slop implementation will do.
        • rfgplk5 hours ago
          The standard library implements really do suck (in some cases), but this should be separated from C++ (the language). Even the standard splits the language grammar from the standard library cleanly.
          • wavemode5 hours ago
            You can&#x27;t really separate the two, firstly because some parts of the standard library interact directly with the language&#x27;s syntax (e.g. &lt;initializer_list&gt;), and secondly because the language standard dictates things about the behavior of the standard library that limit implementation options.<p>For example, the standard says that adding elements to an &lt;unordered_map&gt; is not allowed to invalidate references to keys or elements within the map. That makes it impossible for any standards-compliant C++ implementation to use a high-performance implementation in which keys and elements are stored contiguously in a flat array.
            • nly3 hours ago
              Your map example only concerns the standard library, not the language.
              • wavemode2 hours ago
                Its behavior is dictated by the language.<p>The context of this thread is that someone stated that the C++ standard library sucks, and someone replied to them saying that it&#x27;s just some implementations that suck, but that&#x27;s separate from the language. The point I&#x27;m trying to make, in response, is that it <i>is</i> about the language. It&#x27;s not just &quot;some&quot; implementations - there is no implementation of the C++ standard library that doesn&#x27;t have these inefficiencies, because the language&#x27;s own standard requires them.<p>(This is tangential but - this is why I often say that C++ is not actually the most complex language in the world, it&#x27;s just over-specified. If you took almost any popular programming language and wrote a document dictating the behavior of every single feature and library to the same level of detail, you would end up with a document similar in length or even longer than the C++ standard.)
                • jstimpfle38 minutes ago
                  In my reading, they didn&#x27;t say it&#x27;s due to bad implementations, though. They were trying to separate the standard into two parts, the one about the language syntax and semantics, and the one about the standard library. And I think this is a fair separation actually. But that doesn&#x27;t make the core language any better ;-)
            • gpderetta4 hours ago
              Which sucks... unless you really need reference stability.
              • jstimpfle2 hours ago
                <i>std::vector has left the chat.</i>
      • flohofwoe4 hours ago
        &gt; Malloc and memory allocation methods are at least 10k+ lines of code for instance.<p>Only the really big ones, e.g. here is Emscripten&#x27;s allocator that focuses on small binary size and is implemented in about 1.5 kloc (ignoring comments and whitespace it&#x27;s actually under 1 kloc), and that allocator is perfectly fine for most use cases (especially C code bases which typically don&#x27;t have a high allocation frequency):<p><a href="https:&#x2F;&#x2F;github.com&#x2F;emscripten-core&#x2F;emscripten&#x2F;blob&#x2F;main&#x2F;system&#x2F;lib&#x2F;emmalloc.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;emscripten-core&#x2F;emscripten&#x2F;blob&#x2F;main&#x2F;syst...</a><p>...and Seb Aaltonen&#x27;s offset allocator (used for allocating GPU buffers in his Vulkan API wrapper) has under 500 lines of code:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;sebbbi&#x2F;OffsetAllocator&#x2F;blob&#x2F;main&#x2F;offsetAllocator.cpp" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;sebbbi&#x2F;OffsetAllocator&#x2F;blob&#x2F;main&#x2F;offsetAl...</a><p>Right tool for the job etc... big general-purpose allocators like jemalloc or mimalloc are usually a bandaid to somewhat salvage a failed memory management strategy.
      • IncreasePosts5 hours ago
        If we accept the maximum that &quot;any sufficiently advanced technology is indistinguishable from magic&quot;, then c++ is indeed magic. It&#x27;s so advanced that one of the worlds foremost experts in the language(herb sutter) has determined that the language is too complex and we need a whole new language(confront) which is simpler and can be converted to c++.
        • rfgplk5 hours ago
          C++ is actually obscenely complex, I don&#x27;t deny that. Just mastering object lifetime rules is crazy difficult due to all the edge cases, but it comes with the territory.
          • tialaramex4 hours ago
            &gt; it comes with the territory<p>In the sense that C++ is complicated because it&#x27;s C++, which is complicated? That&#x27;s just a tautology. If you mean &quot;the territory&quot; in some other sense there&#x27;s no reason to believe this.
      • Chaosvex3 hours ago
        [dead]
    • badsectoracula1 hour ago
      &gt; for (auto const &amp; ess : esses) {<p>The problem with this is that whoever is reading the code <i>as-is</i> does not know what type &quot;ess&quot; is. Sometimes you get the definition somewhere nearby, in which case it is probably fine - assuming it is close enough that it&#x27;ll be included in a diff - but more often than not you don&#x27;t know.<p>Yes, an IDE can probably tell you (probably, depends on the IDE and assuming everyone uses one) but even that requires some extra action like moving the mouse over the definition and hoping it&#x27;ll give you something. However this wont show up in diffs, PRs, code reviews, etc.<p>IMO `auto` is one of those C++ features that <i>really</i> needs discipline to use - and when in doubt, i&#x27;d rather ban its use (except where you cannot do otherwise) than rely on everyone doing the right thing.
      • wk_end1 hour ago
        How important is that, the ability to be certain of the type of some iterated value from a container from one line in total isolation? The odds are very good that it&#x27;s clear from the context, which is why the compiler can infer it easily enough too. And then the consequence of not inferring correctly would be...the code doesn&#x27;t compile?<p>Of course some discipline is required - as with just about everything in programming, <i>especially</i> in C++ - but developers in just about every other statically-typed language lean on type inference (including far more extensive type inference) and don&#x27;t wring their hands about it. It&#x27;s hard not to see this as a case of Blub - if you learned about typing with `Foo foo = new Foo()`, anything different might seem scary.<p>...anyway, in this case the real win probably is the range-based for loop, rather than the auto. `for (const Foo&amp; foo : foos)` isn&#x27;t so bad, but `for (std::vector&lt;Foo&gt;::const_iterator it = foos.begin(); it != foos.end(); ++it)` is pretty rough.
        • badsectoracula50 minutes ago
          &gt; How important is that, the ability to be certain of the type of some iterated value from a container from one line in total isolation?<p>As important as the code to be readable.<p>&gt; The odds are very good that it&#x27;s clear from the context<p>As i wrote, if the actual type can be seen somewhere nearby (close enough to be included in diffs) then that&#x27;s fine - it is already in the context. Though that is not usually the case and i personally had to work with code with which i was not familiar and which used `auto` all over the place and had to go hunting for the actual container declaration to see what it is (Visual Studio was not helpful in its tooltips).<p>So my actual experience is that i&#x27;d rather see the actual type.<p>However...<p>&gt; anyway, in this case the real win probably is the range-based for loop<p>...yes, the range-based for loop is often the better choice when it comes to readability. And when compared with the iterators, it is pretty much always more readable than them :-P. `for (const Foo&amp; foo : foos)` is basically what i&#x27;d prefer to see. It is the use of `auto` i pointed out.
    • flohofwoe4 hours ago
      &gt; for (auto const &amp; ess : esses) {<p>This is allowed by Orthodox C++<p>&gt; dynamic_cast&lt;Derived&gt; (base_ptr)<p>This isn&#x27;t because it requires RTTI, but dynamic_cast is also a typical code smell.<p>Orthodox C++ isn&#x27;t generally against new C++ features, it only advices to wait about 5 years (or at least one C++ version) for stabilization and to apply some common sense before adopting them.<p>The notes about not using RTTI, exceptions and stdlib features that allocate under the hood are all justified by painful experience with those things in the context of game development.<p>In general, the restrictions outlined in the post make a lot of sense when considering that Branimir (of BGFX fame: <a href="https:&#x2F;&#x2F;github.com&#x2F;bkaradzic&#x2F;bgfx" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bkaradzic&#x2F;bgfx</a>) is coming out of the game dev hemisphere, and from that PoV none of the restrictions are controversial - on the contrary, it would be highly controversial to suggest going all in on Modern C++ features ;)
      • PaulDavisThe1st2 hours ago
        &gt; This is allowed by Orthodox C++<p>I can see no rationale for this whatsoever. It is nothing but syntactic sugar.<p>&gt; Branmir (of BGFX fame<p>Appeals to authority don&#x27;t really work for me.<p>I&#x27;ve been writing a cross-platform DAW (0) for 25+ years, in C++, and what a game dev has to say about the language in their own work might be of passing interest but not much more.<p>Being aware of the pitfalls of particular features of a language is an important task for anyone programming in that language. But that doesn&#x27;t mean that the language is fundamentally broken or that programmers cannot make their own choices about which features to use.<p>(0) on at least the same level of complexity as a modern game
        • forrestthewoods28 minutes ago
          Your level of vitriol and anger at someone expressing an opinion is really weird.<p>Literally everyone who uses C++ decides which features to use&#x2F;embrace and which to avoid. Someone sharing their particular preference is pretty normal and fine.<p>&gt; Appeals to authority don&#x27;t really work for me. I&#x27;ve been writing a cross-platform DAW (0) for 25+ years, in C++<p>I love how you reject appeal to authority and then try to establish yourself as an authority. That’s cute.
    • cyber_kinetist5 hours ago
      LLVM uses a hand-rolled version of RTTI for the best performance (the parent constructor accepts its runtime type as an enum), and it seemed that the maintenance costs for it aren&#x27;t that high. (See <a href="https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;HowToSetUpLLVMStyleRTTI.html" rel="nofollow">https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;HowToSetUpLLVMStyleRTTI.html</a>)<p>Or if you&#x27;re even lazier, you can easily make a more automatic RTTI system with some templates &#x2F; macros that works much faster than dynamic_cast! (See <a href="https:&#x2F;&#x2F;github.com&#x2F;royvandam&#x2F;rtti" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;royvandam&#x2F;rtti</a>)
    • my-next-account5 hours ago
      Implementing STL iterators are a bloody PITA
      • flohofwoe4 hours ago
        You don&#x27;t need iterators for the range-based for loop, just a .begin() and .end() method which returns a raw pointer is enough.<p>E.g.:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;floooh&#x2F;oryol&#x2F;blob&#x2F;eb08cffe1b1cb6b05ed14ec692bca9372cef064e&#x2F;code&#x2F;Modules&#x2F;Core&#x2F;Containers&#x2F;Array.h#L127-L134" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;floooh&#x2F;oryol&#x2F;blob&#x2F;eb08cffe1b1cb6b05ed14ec...</a><p>(don&#x27;t use that project though because it&#x27;s been archived, I&#x27;ve switched back to plain old C in the meantime)
  • rfgplk6 hours ago
    I&#x27;ve developed a style that I legitimately call Heterodox C++ (mainly due to the popularity of Orthodox C++), it is effectively a purely functional &amp; metaprogramming heavy style of C++. Quite the opposite of this, not everyones cup of tea, and it won&#x27;t fit into every codebase but it is incredibly powerful. The template metaprogramming C++ offers is the most powerful of any imperative language, and (subjective opinion) is second only to Lisp, but few people make use of it. With some of C++26 features you can almost even replicate most of Rusts safety features in pure C++ (via function tagging + reflection)
    • kartoffelsaft4 hours ago
      &gt; The template metaprogramming C++ offers is the most powerful of any imperative language<p>I&#x27;m curious what languages you&#x27;re comparing to here. Feels like it&#x27;s only slightly more expressive than pure generics, but I admittedly haven&#x27;t done much template metaprogramming myself. How does it compare to, say, Zig&#x27;s comptime?
      • lumrn46 minutes ago
        I’ll preface this by saying I mostly use C++ and have just basic experience in Zig, but as far as I understand comptime is much more procedural than C++ templates which are more declarative. With templates you get quite good pattern matching through the compiler’s machinery, for instance through template specialisation, while Zig, in my understanding, requires these to be handled manually in code. Personally, comptime feels like constexpr&#x2F;consteval in C++ but with the ability to interact with the type system itself. The significant downside of C++ metaprogramming is that sometimes many features interact weakly and feel very much tacked on top of each other while Zig’s looks more cohesive. Perhaps someone with more Zig experience can weigh in.
    • cyber_kinetist5 hours ago
      The problem with metaprogramming-heavy C++ codebases is always compilation times and obtuse error messages...<p>Template metaprogramming is sometimes very useful to get around C++&#x27;s language restrictions, but I tend to use it sparingly.
      • nly5 hours ago
        &gt; obtuse error messages<p>With concepts and constexpr-if and consteval it&#x27;s increasingly less of a problem
    • undershirt6 hours ago
      have you written about this anywhere, or hosting any examples?
      • rramadass6 hours ago
        You might find <i>Functional Programming in C++ by Ivan Cukic</i> relevant.
      • rfgplk6 hours ago
        Not yet, I might one day.
    • unnah6 hours ago
      C++ template metaprogramming is in some ways more powerful than Common Lisp macros, because it works at the type level: you can generate new types and dispatch into separate implementations by type. In contrast, Common Lisp type declarations are not available at macro expansion time unless you implement a full source-to-source translator in macros.
  • aw16211076 hours ago
    Submitted a fair few times previously. HN&#x27;s search turned up these submissions with some additional discussion:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40445536">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=40445536</a> (2 years ago, 63 points, 66 comments)<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25554018">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=25554018</a> (5 years ago, 70 points, 102 comments)<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13751244">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13751244</a> (9 years ago, 29 points, 14 comments)<p>Looks like the page was moved from a GitHub gist to a github.io page in October of last year.
    • rramadass6 hours ago
      Yep, the article is a old one and not particularly well written. As somebody who has been using C++ from the early 90s and not particularly a fan of (all of) &quot;Modern C++&quot;, there is not much information here.
  • badlibrarian6 hours ago
    If you&#x27;re in a market that requires using C++, many of these decisions are made for you by the platform above you, and you&#x27;re screwed. Turn on RTTI, build a fort to deflect the random exceptions they&#x27;ll throw at you, and may the gods allow you to recoup your R&amp;D before some well-intentioned yokel in some media or game vertical changes everything and requires you to change everything.<p>On the other hand, if you control your own destiny and care about velocity and code quality, many of these choices eventually become self-evident.<p>If you are messing around with the latest and greatest esoteric C++ stuff in 2026, bless you, you beautiful nerd. But it may be time to start evaluating where you are in life, and how you got here. (And if you&#x27;re on a C++ committee, I revoke those blessings.)<p>For those who remain: if you have a C++ code base yet somehow have enough time and energy to write opinionated blog posts, it&#x27;s really hard to imagine why you think you&#x27;d have a better take on this than Google.<p><a href="https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html" rel="nofollow">https:&#x2F;&#x2F;google.github.io&#x2F;styleguide&#x2F;cppguide.html</a>
    • dataflow5 hours ago
      &gt; build a fort to deflect the random exceptions they&#x27;ll throw at you<p>Sounds like you hate exceptions, right? In which case why do you handle them at all? Just leave them all unhandled and suddenly every exception is a crash. Which is really no different from someone choosing to terminate. Which you have to worry about even without exceptions.<p>&gt; if you have a C++ code base yet somehow have enough time and energy to write opinionated blog posts, it&#x27;s really hard to imagine why you think you&#x27;d have a better take on this than Google.<p>&quot;Given that Google&#x27;s existing code is not exception-tolerant [...] Our advice against using exceptions is not predicated on philosophical or moral grounds, but practical ones. [...] <i>Things would probably be different if we had to do it all over again from scratch.</i>&quot;
      • patrick4514 hours ago
        &gt; Which is really no different from someone choosing to terminate.<p>If you std::abort(), you&#x27;ll get a useful stack trace in the core dump. If you crash from an unhandled exception, you don&#x27;t. That&#x27;s a pretty huge difference and is one of the reasons exceptions suck.
        • cpgxiii1 hour ago
          &gt; If you std::abort(), you&#x27;ll get a useful stack trace in the core dump. If you crash from an unhandled exception, you don&#x27;t. That&#x27;s a pretty huge difference and is one of the reasons exceptions suck.<p>All of this is up to the implementation in practice. The codebases I work on generally follow the pattern that exceptions <i>may be thrown</i> but <i>may not be caught</i>*, and thus they practically serve as terminate. And we absolutely get stack traces in our core dumps (Linux, both GCC and clang), and basically all of the complex debugging I do starts with a coredump stacktrace.<p>* We follow this pattern for a few reasons, (1) it is generally safer for us to assume that libraries we consume (STL included) will behave as expected with exceptions enabled, (2) &quot;don&#x27;t catch exceptions&quot; (or if you must, catch the as close-to-throw as possible) is a simple way to avoid exceptions-for-nonexceptional-cases control flow, and (3) most of the C++ codebase is exposed through bindings in Python, and propagating errors as exceptions is the only Python-friendly way to handle it.
        • dataflow3 hours ago
          That&#x27;s nice but it&#x27;s certainly not guaranteed by anything, just something provided by your toolchain or platform. (&quot;Core dumps&quot; aren&#x27;t even a thing in C++.)<p>If you&#x27;re looking for implementation-specific guarantees then you could make that happen with exceptions too. I <i>think</i> on GCC replacing a function like __cxa_throw might be sufficient to let you capture a stack trace?<p>If you&#x27;re looking for source-level-only guarantees then another option is to just replace your throw &lt;expr&gt; statements with one that attaches whatever extra info you want. You could literally script this to patch your external repos automatically too. Or heck, maybe you could even just define throw to be a macro that shoves your stack trace into some global variable before actually throwing.
      • badlibrarian5 hours ago
        [flagged]
    • demorro1 hour ago
      &gt; it&#x27;s really hard to imagine why you think you&#x27;d have a better take on this than Google.<p>Do you mean this as an appeal to Google being the home to great talent, or more as an endorsement of the specific guidance provided by this specific style guide, Google or no?<p>Because if the former, I think I do almost everything better in my context than Google would. It would be hard not to considering the difference in organizational scale.
    • otabdeveloper44 hours ago
      I interview C++ developers often, and here in 2026 it seems pretty much everyone is using modern (C++20 and up) language versions.<p>Maybe the tooling finally caught up.
  • canyp5 hours ago
    My codebase uses a fairly dumbed down version of C++, but I would have liked to see more depth in this post. As it is, it is not very useful.<p>There are many more things to avoid than just iostream. HFT university has a good recap: <a href="https:&#x2F;&#x2F;hftuniversity.com&#x2F;post&#x2F;the-c-standard-library-has-been-walking-itself-back-for-fifteen-years-and-the-receipts-are-public" rel="nofollow">https:&#x2F;&#x2F;hftuniversity.com&#x2F;post&#x2F;the-c-standard-library-has-be...</a><p>The point on exceptions I think is also misleading. Compilers typically make throwing an exception the expensive part, and the happy path inexpensive (not more expensive than a branch checking for errors, which should be the baseline for comparison, not an implementation with zero error checking.) So to say that they are &quot;expensive&quot; doesn&#x27;t really make a useful argument.<p>And there are more things that could be done in this camp, like proposing a set of compiler flags, and a linter to enforce the subset you are subscribing to. Unfortunately the post offers none of that.
    • gpderetta4 hours ago
      [from the linked article]<p>&gt; &lt;deque&gt;: Needs a major performance overhaul&quot;, acknowledging that the standard&#x27;s mandated block size is too small and the design needs to be rebuilt at the next ABI break<p>Except of course the standard does not mandate a block size. That&#x27;s purely msvc picking a wrong block size and being stuck with it.<p>The rant about lists is also nonsense.
    • PaulDavisThe1st2 hours ago
      &gt; There are many more things to avoid than just iostream.<p>But even &quot;avoiding iostream&quot; is stupid. The author presumably really means &quot;avoid operator&gt;&gt; and operator&lt;&lt; for I&#x2F;O&quot;. Even using type-safe printf-like stuff ultimately still sits on top of iostream.
    • Chaosvex2 hours ago
      AI slop article.
  • ok1234565 hours ago
    stringstreams and fmt are a godsend compared to printf&#x2F;scanf, which have historically led to most memory bugs in the first place!<p>Printf&#x2F;scanf are implemented as variadic functions without type checking and rely on the compiler to perform its own internal metaprogramming to inspect and warn about format mismatches.<p>Anyone advocating the use of the old cstdio as a primary design decision about which C++ language features to use is not serious.<p>No exceptions or RTTI make sense in an embedded system that needs to ensure determinism, but are arbitrary and unnecessarily hobbling for high-level systems and application programming. How do you do runtime method dispatch without creating vtables and RTTI from first principles? How do you propagate a runtime error deep from the bowels of a component all the way to some top-level event loop? The &quot;orthodox&quot; approach would be a mess of integer return codes with associated enums (and none of that enum class nonsense!). No Thanks. It&#x27;s clear the author has no idea what he&#x27;s talking about.
  • nasretdinov6 hours ago
    Such a missed opportunity to call it C &lt;orthodox cross emoji&gt;
    • greenbit5 hours ago
      Was thinking &quot;Hesitance C&quot; could work
    • undershirt6 hours ago
      that&#x27;s one way to combine three plus signs!
  • wseqyrku40 minutes ago
    Might as well use Rust. Basically if you have a <i>choice</i>, using C++ over Rust is kind of stupid in 2026, to be honest.
  • asveikau5 hours ago
    The criticisms of STL and allocation are fair, though move constructors improved the shallow vs deep copy problem on resize.<p>Smart pointers are good. People were doing them outside the standard in the late 90s.<p>Lambdas are a good feature.
  • kabdib5 hours ago
    I&#x27;ve been doing embedded systems in C++ since rocks were young, and this is a great summary of what to avoid.<p>I would sure love a good coroutine runtime, and first-class support for defer. You can do these manually, but language&#x2F;toolchain&#x2F;debugger support is nice to have.<p>(Pragmatically, I will be retired by the time they would be useful)
    • usrnm5 hours ago
      A defer is just a dozen lines of code nowadays, if you really need it, but in most cases you don&#x27;t if you&#x27;re doing RAII
    • wglb5 hours ago
      It is still a bit amazing to me that it was significantly easier to do coroutines in Sigma 5 assembly and likely most any assembly than in C or C++. Two languages supposedly close to the machine.
      • kabdib4 hours ago
        I have seen a pure C&#x2F;C++ implementation of coroutines (it used setjmp&#x2F;longjmp, and memcpy to copy stacks in and out of the native arena). Not the most portable of constructions, but it worked absurdly well.<p>Being able to write &quot;async&quot; code essentially in-line is a superpower.
        • wglb3 hours ago
          Agree but nowhere as easy as what we did <a href="https:&#x2F;&#x2F;ciex-software.com&#x2F;coroutines.html" rel="nofollow">https:&#x2F;&#x2F;ciex-software.com&#x2F;coroutines.html</a>
    • AnimalMuppet5 hours ago
      In embedded, I like wrapping a class around a set of registers. Nobody else gets to write to that piece of hardware except that class.<p>As far as avoiding things... avoid basically everything you don&#x27;t need. Don&#x27;t add language features that don&#x27;t actually help you, just because they&#x27;re there. Keep the subset you use small. But pick that subset to match your problem well, rather than out of dogma.
  • Martin_Silenus5 hours ago
    Nothing surprising here. People who view C++ as just a better C always outnumbered those who view it as another language.<p>That&#x27;s exactly how democratic governments make their decisions… you might think it&#x27;s stupid, and you&#x27;d be right, but that&#x27;s democracy. It&#x27;s the majority that counts, not what&#x27;s right. At least you can have a little fun with their arguments, they&#x27;re pretty inventive you know.
  • aleksiy1235 hours ago
    Somewhere within c++ there is a subset of c++ that is a great language.<p>The problem of course is that no one agrees on which subset that is.
  • greenbit5 hours ago
    Sometimes I actually want objects that are transparent, fully public, and &#x27;struct&#x27; is perfect for that. But if I then go and put methods into those structs, does that make me unorthodox?
    • blashyrk5 hours ago
      That&#x27;s simply because we live in a world where UFCS is restricted to niche languages and we&#x27;re stuck with &quot;methods&quot; instead. At least Rust&#x2F;Kotlin&#x2F;Swift support type extensions (with a thousand papercuts, i. e orphan rules)
    • rramadass4 hours ago
      No, it is perfectly valid if your design demands it.<p>For example, the Windows MFC framework had classes whose data members were all public. Some of reasons were;<p>1) MFC was a wrapper over lower-level Windows API&#x2F;structs and therefore unnecessary getter&#x2F;setter methods were avoided. The C++ class could be a simple wrapper over the underlying C-style POD.<p>2) The framework classes were supposed to be used by implementation inheritance to build one&#x27;s skeleton application which led to tight coupling between base and derived classes. Hence the designers decided to make all members public which meant that users were not limited by any omissions in the basic design.<p>I actually used these ideas in a project where i implemented a C++ api over C state machines for H.323 protocols.
    • badlibrarian5 hours ago
      [flagged]
  • einpoklum46 minutes ago
    I&#x27;m not opposed to the concept, but the definition is problematic:<p>&gt; <i>Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It’s exactly opposite of what Modern C++ suppose to be.</i><p>&quot;Modern C++&quot; is usually considered to mean the significant changes to the language in 2011, or 2011 and later. The thing is, that a &quot;small subset improving over C&quot;, and without &quot;unnecessary things&quot; will not necessarily avoid 2011-and-later language features, and splurge with pre-2011 features. And this becomes clear as you read the recommendation. So, it&#x27;s recommand to avoid:<p>* exceptions<p>* STL objects which allocate memory<p>* C++ streams<p>all C98 features. On the other hand, it&#x27;s not recommended to avoid constexpr, and it is in fact hinted it is useful.<p>-----<p>C++ is a multi-paradigmatic language. It has lots of features, in the language and via the standard library. It is perfectly reasonable and legitimate to pick feautres which are well-tested enough; or well-regarded by, say, embedded or game developers, or doesn&#x27;t seem too outlandish coming from C. Of course, different people will quibble over what exactly to adopt or discard, but I&#x27;m sure that different flavors of &quot;orthodox C++&quot;, &quot;sane C++&quot;, etc. are in fact used by many groups of developers.
  • gpderetta6 hours ago
    Don&#x27;t follow dogma.
  • yyx6 hours ago
    At this point, if you want better C, just use Zig.
    • pjmlp5 hours ago
      Except it is years away of being 1.0, with the industry support of C++.
  • BiraIgnacio5 hours ago
    Holly bananas, that Boost Design Rationale post is, what&#x27;s the word I&#x27;m looking for, intense.
  • rfgplk6 hours ago
    This is gonna be a long critique, I&#x27;ll try to keep it concise.<p>&gt; C-like C++ is good start, if code doesn’t require more complexity don’t add unnecessary C++ complexities.<p>C is almost obsolete nowadays. Not to mention that C++ is effectively a strict superset of C (nearly 99% of the C standard is in C++) and the few features that aren&#x27;t are included as compiler extensions (VLA, restrict keyword, nested functions). There are a handful of C features that aren&#x27;t in C++, and for very good reason (most of them suck). When was the last time you ran into a C library that a pure C++ compiler couldn&#x27;t compile? Only if someone decided to spam the new keyword all over the codebase (or something similar).<p>&gt; In general case code should be readable to anyone who is familiar with C language.<p>Most C++ already is? Even very template heavy C++.<p>&gt; Don’t do this, the end of “design rationale” in Orthodox C++ should be immedately after “Quite simple, and it is usable. EOF”.<p>A lot of the methods in that document are necessary to make C++ shine, especially template metaprogramming.<p>&gt; Don’t use exceptions.<p>Optional but irrelevant.<p>&gt; Don’t use RTTI.<p>.. Why? Reimplementing RTTI in C will give you almost the same overhead.<p>&gt; Don’t use C++ runtime wrapper for C runtime includes (&lt;cstdio&gt;, &lt;cmath&gt;, etc.), use C runtime instead (&lt;stdio.h&gt;, &lt;math.h&gt;, etc.)<p>.. Why? Those wrappers all include the &quot;raw C runtime&quot; under the hood (literally they do #include &lt;stdio.h|xx&gt;. Near 0 compiletime overhead?<p>&gt; Don’t use stream (&lt;iostream&gt;, &lt;stringstream&gt;, etc.), use printf style functions instead.<p>This is a design decision.<p>&gt; Don’t use metaprogramming excessively for academic masturbation. Use it in moderation, only where necessary, and where it reduces code complexity.<p>There are many programs that are _impossible_ to write in a finite time without metaprogramming. How will you (with zero runtime overhead) dispatch a function with a variable arity of random types to a handler that requires exactly that type of function? Arbitrarily? In C++ it&#x27;s possible, in C it isn&#x27;t.
    • ndiddy5 hours ago
      &gt; When was the last time you ran into a C library that a pure C++ compiler couldn&#x27;t compile? Only if someone decided to spam the new keyword all over the codebase (or something similar).<p>In C, you can use goto to jump over a variable declaration, and you can&#x27;t in C++. I understand why this is, but it&#x27;s the thing I see the most often that makes C code not compile as C++.
    • pjmlp5 hours ago
      For me it was already obsolete in 1992, when I was given a copy of Turbo C++ 1.0 for MS-DOS.<p>It was the next step from Turbo Pascal in terms of safety, with added benefits from cross platform.<p>Nowadays all C compilers that matter are written in C++ anyway.
    • tialaramex4 hours ago
      &gt; nearly 99% of the C standard is in C++<p>But, one of the annoying habits of WG21 (the C++ committee) is sending stuff to WG14 (the C committee) to have them make it part of their language rather than accept that it&#x27;s a C++ problem. Even the stupid type qualifiers are actually C++&#x27;s fault, K&amp;R doesn&#x27;t have this abomination but the pre-standard C++ did so too bad now it&#x27;s in C89.
    • AnimalMuppet5 hours ago
      &gt; &gt; Don’t do this, the end of “design rationale” in Orthodox C++ should be immedately after “Quite simple, and it is usable. EOF”.<p>&gt; A lot of the methods in that document are necessary to make C++ shine, especially template metaprogramming.<p>So? Is your goal to make C++ shine, or is it to produce useful, understandable code? My goal is good code, not being a showoff.
  • sudosteph6 hours ago
    And here I was thinking this was going to be about a schism from Holy C [1]<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;TempleOS#HolyC" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;TempleOS#HolyC</a>
  • fithisux5 hours ago
    I wish the site listed compiler flags for the most popular compilers.
  • jstimpfle5 hours ago
    Orthodox C++, to me, is C plus the one good feature of C++: you don&#x27;t have to type struct all the time.
    • maxvu5 hours ago
      How about one of the C unorthodoxies that use typedef everywhere? (Namespaces seem suitable, too.)
      • jstimpfle5 hours ago
        typedef is a little bit of a hassle but you can do it, even in a very strict mechanical way if writing plain C. But it&#x27;s a hassle.<p>And namespaces suck too, so much noise for little gain. You know what, a big part of programming is naming. You just have to come up with good names. Namespaces don&#x27;t magically make names better, if anything, they make them worse. And they add a lot of syntax noise.
        • PaulDavisThe1st2 hours ago
          tell me you never use platform-provided or third party libraries without actually telling me.
          • jstimpfle46 minutes ago
            I won&#x27;t, because obviously I have. Coincidentally, I&#x27;ve just spent more than a day to find a sane way to setup basic windowing and rendering on Windows for the 1000st time -- this time based on Direct3D compute shader and DirectComposition. Going to integrate my Direct2D&#x2F;DirectWrite based UI library with those technologies in a bit.<p>And I&#x27;m working on this project because the material removal simulation library that my company has been paying insane amounts of money for in the last 10 years just doesn&#x27;t &quot;cut&quot; it for our grinding purposes (independently of the cruelfully bad C++ API, and the ~10x worse performance in their debug build because of all those dumb C++ objects inside), and it requires an insane amount of BS architecture around on our part to even use it, so I&#x27;ve concluded (after my own short periods of serious well-meaning suffering with this library on and off during the last 2 years), it should actually be way easier to make our own grinding simulation in a short time after running the numbers and concluding a realistic magnitude.<p>Guess what, I still see no reason why my little project shouldn&#x27;t succeed, I&#x27;ve seriously come closer to realizing it, but COM Objects by Microsoft are once again not the reason why that is so. On the contrary, they are annoying to use (I&#x27;m not a newcomer to them), even though there are a lot of nice things to say about Microsoft APIs as well (and OpenGL should just die), it seems like a layer of bullshit to wade through for no obvious reason.<p>The nicest libraries in terms of usability have always been those with a simple &amp; straightforward plain C interface.
  • netbioserror5 hours ago
    Man, all of the confusion and gnashing of teeth in the C++ world really makes me grateful for my job. Smaller company, I solo develop a central module on the product stack, and I was able to evaluate languages for the project.<p>Nim became the obvious choice, and I wasn&#x27;t a fanboy before. Simple semantics, in a very functional style oriented around data&#x27;s value. References and identity have to be trapdoored. Everything is single-owner unique lifetimes by default, no annotations or best-practices required. You end up writing extraordinarily functional&#x2F;procedural code that produces very fast and memory-safe binaries, it fits right into C++&#x27;s niche.<p>The only objection I could steel man was that the standard library and most packages are composed of relatively pure functions that return new values, so allocations are happening there. But when types as complex as data frames can be semantically used as just values, and you know they have scoped lifetimes by default, the benefits are obvious.<p>With all of C++&#x27;s insanely specific, subtle, implicit, compiler- and platform-dependent behaviors, I&#x27;ve often wondered when the industry will finally consider its dominance an artifact of first-mover inertia and simply move on. There are vastly better ways to do all of the things it does, while easily exposing levers for the the things it&#x27;s considered to do exceptionally well.