3 comments

  • fsloth5 hours ago
    I get the feeling author would just like to use a better language, like F# or Ocaml, and completely misses the point what makes C++ valuable.<p>C++ is valuable, because the existing tooling enables you to optimize the runtime peformance of a program (usually you end up with figuring out the best memory layout and utilization).<p>C++ is valuable becaus it&#x27;s industry support guarantees code bases live for decades _without the need to modify them_ to latest standards.<p>C++ is valuable because the industry tooling allows you to verify large areas of the program behaviour at runtime (ASAN etc).<p>I simply don&#x27;t understand what type of industrial use this type of theoretical abstraction building serves.<p>Using the metaprogramming features makes code bases extremly hard to modify and they don&#x27;t actually protect from a category of runtime errors. I&#x27;m speaking from experience.<p>I would much rather have a codebase with a bit more boilerplate, a bit more unit tests and strong integration testing suite.<p>The longer I use C++ the more I&#x27;m convinced something like Orthodox C++ is the best method to approach the language <a href="https:&#x2F;&#x2F;bkaradzic.github.io&#x2F;posts&#x2F;orthodoxc++&#x2F;" rel="nofollow">https:&#x2F;&#x2F;bkaradzic.github.io&#x2F;posts&#x2F;orthodoxc++&#x2F;</a><p>This keeps the code maintainable, and performant (with less effor than metaprogramming directed C++).<p>Note: the above is just an opinion, with a very strong YMMV flavour, coming from two decades in CAD, real time graphics and embedded development.
    • pjmlp1 hour ago
      As someone that had the option to choose between C and C++, coming from compiled BASIC and Object Pascal backgrounds, back in the early 1990&#x27;s.<p>What makes C++ valueable is being a TypeScript for C, born in the same UNIX and Bell Labs farm (so to speak), allowing me to tap into the same ecosystem, while allowing me to enjoy the high level abstractions of programming languages like Smalltalk, Lisp, or even Haskell.<p>Thus I can program on MS-DOS limited with 640 KB, an ESP32, Arduino, a CUDA card, or a distributed system cluster with TB of memory, selecting which parts are more convinient for the specific application.<p>Naturally I would like in 2025 to be able to exercise such workflows with a compiled managed language instead of C++, however I keep being in the minority, thus language XYZ + C++ it is.
      • AnimalMuppet9 minutes ago
        Does go count as managed, in your view? (Honest question - I don&#x27;t know go well enough to have much of an opinion.)
    • jandrewrogers2 hours ago
      C++20 inverts the traditional relationship between the core language and metaprogramming, which arguably makes it new language in some ways. Instead of being a quirky afterthought, it has become the preferred way to interact with code. There is a point of friction in that the standard library doesn’t (and can’t) fully reflect this change.<p>Metaprogramming style in C++20 only has a loose relationship to previous versions. It is now concise and highly maintainable. You can do metaprogramming in the old painful and verbose way and it will work but you can largely dispense with that.<p>It took me a bit to develop the intuitions for idiomatic C++20 because it is significantly different as a language, but once I did there is no way I could go back. The degree of expressiveness and safety it provides is a large leap forward.<p>Most C++ programmers should probably approach it like a new language with familiar syntax rather than as an incremental update to the standard. You really do need to hold it differently.
      • jebarker21 minutes ago
        As someone that has only dabbled in C++ over the past 10 years or so, it feels like each new release has this messaging of “you have to think of it as a totally new language”. It makes C++ very unapproachable.
        • gpderetta9 minutes ago
          As someone that has been using C++ extensively for the last 25 years, each release has felt as an incremental improvement. Yes, there are big chunks in each release that are harder to learn, but usually a team can introduce them at their own pace.<p>The fact that C++ is a very large and complex language and that makes it unapproachable is undeniable though, but I don&#x27;t think the new releases make it significantly worse. If anything, I think that a some of the new stuff does ease the on-ramp a bit.
      • pjmlp1 hour ago
        I only which concepts were easier, those of use that don&#x27;t use C++ daily have to look the expression syntax all the time, much better than the old ways I guess.
    • ghosty14139 minutes ago
      &gt; C++ is valuable, because the existing tooling enables you to optimize the runtime peformance of a program<p>This is true for MANY other languages too, I don&#x27;t see how this makes c++ different. With gdb its quite the opposite, handlig c++ types with gdb can be a nightmare and you either develop your own gdb glue code or write c-like c++.<p>&gt; C++ is valuable becaus it&#x27;s industry support guarantees code bases live for decades _without the need to modify them_ to latest standards.<p>In times of constant security updates (see the EU&#x27;s CRA or equivalent standards in the US) you always gotta update your environment which often also means updating tooling etc. if you don&#x27;t wanna start maintaining a super custom ecosystem.<p>I don&#x27;t see this as a positive in general, there is bit rot and a software that is stuck in the past is generally not a good sign imo.<p>&gt; C++ is valuable because the industry tooling allows you to verify large areas of the program behaviour at runtime (ASAN etc).<p>Sanitizers are not C++ exclusive too and with rust or C# you almost never need them for example. Yes C++ has extensive debugging tools but a big part of that is because the language has very few safeguards which naturally leads to a lot of crashes etc..<p>I think the idea of using only a small subset of C++ is interesting but it ignores the problem that many people have, you don&#x27;t have the time to implement your own STL so you just use the STL. Ofc it gives me more control etc. but I&#x27;d argue most of the time writing orthodox c++ won&#x27;t save time even in the long run, it will save you headaches and cursing about c++ being super complicated but in the end in modern environments you will just reinvent the wheel a lot and run into problems already solved by the STL.
      • mkornaukhov16 minutes ago
        &gt; handlig c++ types with gdb can be a nightmare and you either develop your own gdb glue code or write c-like c++.<p>That&#x27;s why better to use lldb and it&#x27;s scripts.<p>&gt; I think the idea of using only a small subset of C++ is interesting but it ignores the problem that many people have, you don&#x27;t have the time to implement your own STL so you just use the STL.<p>Yeah, agree. It&#x27;s just much easier to take a &quot;framework&quot; (or frameworks) where all the main problems solved: convenient parallelism mechanisms, scheduler, reactor, memory handling, etc. So it&#x27;s turning out you kinda writing in your own ecosystem that&#x27;s not really different from another language, just in C++ syntax.
    • jokoon13 minutes ago
      orthodox C++ should be a subset of C++, I would really use it, like if there was a compiler flag<p>I can imagine it might be insanely faster to compile
    • gpderetta4 hours ago
      sorry, I can&#x27;t take something that argues for &quot;printf&quot; in favour of anything else seriously.
      • locknitpicker2 hours ago
        &gt; sorry, I can&#x27;t take something that argues for &quot;printf&quot; in favour of anything else seriously.<p>I think you&#x27;re arguing from a position of willful ignorance. The article is clear on how it lauds C++&#x27;s std::printnl, not printf.<p><a href="http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;io&#x2F;println.html" rel="nofollow">http:&#x2F;&#x2F;en.cppreference.com&#x2F;w&#x2F;cpp&#x2F;io&#x2F;println.html</a><p>Here&#x27;s what the article argues:<p>&gt; With std::format, C++ has gained a modern, powerful, and safe formatting system that ends the classic, error‑prone printf mechanisms. std::format is not merely convenient but fully type‑safe: the compiler checks that placeholders and data types match.<p>Solid remark, and the consensus on how std::printnl and std::format are an important improvement over std::cout or C&#x27;s printf.
        • gpderetta51 minutes ago
          I was referring to the Orthodox C++ article linked by parent. Of course format is an improvement on both printf and iostream.
      • unwind3 hours ago
        The article argues that modern C++ has type-checked string formatting, so it does not argue for (unchecked) `printf()`, right?
        • vintagedave2 hours ago
          &quot;The article&quot; is ambiguous. The one this HN post is about does not argue for it, at all. But the one in the comment above directly says,<p>&gt; Don’t use stream (&lt;iostream&gt;, &lt;stringstream&gt;, etc.), use printf style functions instead.<p>and has a code example of what they argue &#x27;Orthodox C++&#x27; should be, which uses printf.<p>I&#x27;m all for a more sensible or understandable C++, but not at the expense of losing safety. In fact I would prefer the other way: I still feel incredibly saddened that Sean Baxter&#x27;s Circle proposal for Safe C++ is not where the language is heading. That, plus some deep rethinking and trimming of some of the worst edge behaviours, and a neater standard library, would be incredible.
          • gpderetta1 hour ago
            I was indeed referring to the &#x27;Orthodox C++ article&#x27;.
      • jstimpfle2 hours ago
        I&#x27;ll bite. printf might be unsafe in terms of typing, in theory, but it&#x27;s explicit and readable (with some caveats such as &quot;PRIi32&quot;). The actual chance of errors happening is very low in practice, because format strings are static in all practical (sane) uses so testing a single codepath will usually detect any programmer errors -- which are already very rare with some practice. On top of that, most compilers validate format strings. printf compiles, links, and runs comparatively quickly and has small memory footprint. It is stateless so you&#x27;re always getting the expected results.<p>Compare to &lt;iostream&gt;, which is stateful and slow.<p>There&#x27;s also std::format which might be safe and flexible and have some of the advantages of printf. But I can&#x27;t use it at any of the places I&#x27;m working since it&#x27;s C++20. It probably also uses a lot of template and constexpr madness, so I assume it&#x27;s going to be leading to longer compilation times and hard to debug problems.
        • TinkersW1 hour ago
          I my experience you absolutely must have type checking for anything that prints, because eventually some never previously triggered log&#x2F;assertion statement is hit, attempts to print, and has an incorrect format string.<p>I would not use iostreams, but neither would I use printf.<p>At the very least if you can&#x27;t use std::format, wrap your printf in a macro that parses the format string using a constexpr function, and verifies it matches the arguments.
          • jstimpfle1 hour ago
            _Any_ code that was never previously exercised could be wrong. printf() calls are typically typechecked. If you write wrappers you can also have the compiler type check them, at least with GCC. printf() code is quite low risk. That&#x27;s not to say I&#x27;ve never passed the wrong arguments. It has happened, but a very low number of times. There is much more risky code.<p>So such a strong &quot;at the very least&quot; is misapplied. All this template crap, I&#x27;ve done it before. All but the thinnest template abstraction layers typically end up in the garbage can after trying to use them for anything serious.
        • gpderetta54 minutes ago
          The biggest issue with printf is that it is not extensible to user types.<p>I also find it unreadable; beyond the trivial I always need to refer to the manual for the correct format string. In practice I tend to always put a placeholder and let clangd correct me with a fix-it.<p>Except that often clangd gives up (when inside a template for example), and in a few cases I have even seen GCC fail to correctly check the format string and fail at runtime (don&#x27;t remember the exact scenario).<p>Speed is not an issue, any form of formatting and I&#x2F;O is going to be too slow for the fast path and will be relegated to a background thread anyway.<p>Debugging and complexity has not ben an issue with std::format so far (our migration from printf based logging has been very smooth). I will concede that I do also worry about the compile time cost.
  • pjmlp5 hours ago
    I still love C++ Builder, regardless of all Borland misteps that lead to where Embarcadero is today, it is the survivor of C++ RAD IDE tooling, Visual C++ never was as Visual as it name implies.
  • yosefk4 hours ago
    &quot;Many—especially historically minded—developers complain that modern C++ compilers take longer to compile. But this criticism is short‑sighted. You cannot compare C++ compile times with compilation in other languages, because the compiler is doing something entirely different.&quot;
    • fsloth53 minutes ago
      A slow compiler impedes developers velocity, not only taking longer, but breaking their concentration.<p>The whole point of a programming language is to be an industrial productivity tool that is faster to use than hand writing assembly.<p>Performance is a core requirement industrial tools. It&#x27;s totally fine to have slow compilers in R&amp;R and academia.<p>In industry a slow compiler is an inexcusable pathology. Now, it can be that pathology can&#x27;t be fixed, but not recognizing it as a pathology - and worse, inventing excuses for it - implies the writer is not really industrially minded. Which makes me very worried why they are commenting on an industrial language.
    • rerdavies3 hours ago
      If only it would do something entirely different faster. :-(<p>Somebody really needs to rethink the entire commitment to meta-programming. I had some hope that concepts would improve reporting, but they seem to actually make it worse, and -- if they improve compile times at all, I&#x27;m not seeing it.<p>And it has nothing to do with historicity. Every time I visit another modern language (or use it seriously) I am constantly reminded that C++ compile times are simply horrible, and a huge impediment to productivity.
    • pjmlp1 hour ago
      We can easily complain, because there were attempts to improve in the past like Energize C++ and Visual Age for C++ v4, or systems like Live++.<p>However too many folks are stuck in the UNIX command line compiler mindset.<p>I keep bumping into people that have no idea about the IDE based compilation workflows from C++ Builder and Visual C++, their multihreaded compilation, incremental compilation and linking, pre-compiled headers that actually work, hot code reloading, and many other improvments.<p>Or the CERN C++ interpreters for that matter.<p>Many don&#x27;t seem to ever have ventured beyond calling gcc or clang with Makefiles, and nothing else.
    • gpderetta3 hours ago
      As a long-time C++ user I definitely complain that C++ takes long to compile. Then again, I always have.
    • ozgrakkurt2 hours ago
      This is also because llvm and gcc are just slow right? Are there any alternative c++ compiler that is faster maybe?