← Back to context

Comment by jdw64

12 hours ago

It's surprising that C++'s development trend continues.

When a game or program is made with C++, it's usually nice because performance is mostly guaranteed. But if someone told me to write C++ myself, I'd cry. There's too much to memorize, and the standards are too varied. When I go to a project site for maintenance and it's a C++ project, I instantly lose energy — because it's just too difficult.

I'd be happy if someone else wrote it, but it's not a language I want to write myself

Personally I don't find programming with C++ that hard. The downside is it needs a brain warm-up, and this is per project, but once that flywheel is spinning, I find it almost effortless to write code.

I have to go through the same warm-up more or less for any language I work with, so it's not that different than writing Python, Go or Java for me.

  • I agree.

    You don't learn or know C++ in the way you learn or know C.

    You never have the total language spec in mind. Much of it you will never (and for some of it should never) come across.

    The way I think of it

    C is an abstraction of the machine, so thin it's nearly transparent.

    C++ is an abstraction over programming paradigms, letting you pick how you think.

    Everything else abstracts the machine away, replacing it with a VM, runtime, or model of its own.

    The same way a good project has a clear model of the problem it should have a clear C++ pattern in use.

    • > C is an abstraction of the machine, so thin it's nearly transparent.

      Looks like someone fell for the C abstract machine trap yet again. No, C is isn’t an abstraction of the machine.

      5 replies →

  • I find C++ not hard at all when working with familiar idioms, restrictions and toolings (familiar to me). But it's hard jumping into new codebases and adjusting yourself to new patterns. Recently I did a lot of programming using C++23 Modules and it was a breeze.

    There's basically dozens of very nice languages inside C++. That can be a blessing or a curse.

    I'm anxious for Herb Sutter's CPP2/CPPFront to become a standard.

  • There are so many standards and idioms that it gets confusing. There are still legacy codebases out there — some codebase still use C++98 as their standard, others use C++11... And with Unreal Engine, the modern C++ standard is C++14, right? There are things like smart pointers, but some places don't even use them. I feel like there are just too many features. When I saw template metaprogramming — that new feature — I realized I have no talent for C++.

    • I have developed things with C++98, C++11 and C++14. Every of these standards are so vast, so remembering everything (even in a single standard) is not possible. Instead of knowing everything, I first fix the standard I want or need to work with.

      Then I design the thing I want to build. I always design what I want to build beforehand. This takes a couple of iterations from high level to low-ish level. That last design becomes a bit language dependent. Then I select some of the core tools that I'm going to use (which kind of pointers, classes or structs, etc.)

      With that design in mind, I go "library shopping" both for file formats (if any) or other stuff like vectors, etc.

      Armed with the reference docs of these, I write my code with the toolbelt I have built for the project.

      Some things are hard, but they are not impossible. I find thinking like compiler helps a lot.

    • This is true of any language. Python with flask vs django, with/without type hints. JavaScript with anhular and vue.

      The varying standards are no different to major python versions or go versions - arguably there’s even less between most versions than there is in your average go release.

      The differences in apps and frameworks don’t matter for day to day - std::string, Unreal’s FString and QT’s QString all are similar enough that 99.9% of the time.

      Metaprogramming is one of those things; you either write it or you don’t. Knowing some basics is required but the vast majority of people use a handful of pre existing things without understanding the nuances of how it works under the hood.

      1 reply →

    • > When I saw template metaprogramming — that new feature — I realized I have no talent for C++.

      It's not a new feature. And tbh, compared to Typescript, C++ templates are tame ;)

      (but yeah, deciding when to stop digging into the template metaprogramming rabbit hole requires some common sense and sanity, too much template complexity is almost never worth the hassle)

      1 reply →

  • > The downside is it needs a brain warm-up, and this is per project, but once that flywheel is spinning, I find it almost effortless to write code.

    How is that different from other languages, which don't need the brain warm-up?

    • The difference, if you split hairs, that the brain warm-up takes a bit longer. Maybe a couple of hours, or a day at most.

      Otherwise it's not different for me. I don't feel different while writing with any other language. I guess the main reason is I always think like the computer first and translate that thinking to the programming language at hand.

For games, C++ becomes a much simpler language since game code bases usually ignore the C++ stdlib (at least mostly, and for good reasons, e.g. see [0]). And without the stdlib C++ is actually kinda-sorta okay-ish.

Related, the main problem with the C++ ecosystem is that everybody carves out their own language subset, so it's not one ecosystem but many ecosystems with contradicting styles and language/stdlib subsets. This makes code reuse via libraries much harder than it should be.

[0] https://hftuniversity.com/post/the-c-standard-library-has-be...

  • I fully agree. In my personal project, I ended up using the STL to get off the ground, but in the end I replaced pretty much everything with custom-written code.

    Once you get rid of the STL, compile times get so much better. With modern c++23 features, templates actually become really convenient to write, and at the core there is a really useful and pleasant to use language.

    I try to avoid c++ libraries and instead rely on c-style APIs. Usually the c++ style libraries force you into using the STL, which comes with a heavy tax on compile times, without much benefit in comfort of use.

  • If you don't use the STL you end up re-implementing it yourself. Usually poorly.

    • > Usually poorly.

      On the contrary. You can focus exactly on the features the higher level game code needs. The C++ stdlib is (for the most part) poorly designed, usually poorly implemented, the main reason for slow build times, and its complexity explodes because it needs to consider all edge cases that most code bases don't ever trigger.

      A specialized dynamic array class in a few hundred lines (at most!) and with just the required features is much more useful than the 20kloc monster that's pulled in with `#include <vector>` and which doesn't even do bounds checking in the 'idiomatic' usage.

      16 replies →

    • The STL is not good if you want performance or predictable behavior. The issue is in the specification and the requirements placed on certain algorithms and data structures. It’s easy to beat unordered_map for example with an open addressing hash map, small vector optimization can’t be implemented in vector due to standard requirements, etc.

    • some of the STL is easy to improve on. For example, std::unordered_map performs poorly due to pointer stability requirements in the standard. Most performance sensitive C++ codebases will use something like abseil's hash maps instead.

      2 replies →

  • Your citation refers to the register keyword and trigraphs, among other language features -- the author seems to have forgotten his own point, among a number of other inconsistencies and contradictions, and at times seems to go out of his way to come across as a jerk, e.g., "This is what fifteen years of standards work on an eight-letter keyword looks like".

    People love to rag on the standards committee. I was on X3J11, the C Language Standards Committee, in 1989 ... in fact, due to alphabetical order I was the first person on the planet to vote to approve the C language standard -- the one that first standardized register and trigraphs. Standards work is hard and everyone hates you for it.

    • The C Committee is fine and doing great work! The C++ Committee could actually learn a thing or two from how things are done on the C side.

      1 reply →

  • That article probably isn't the best source to cite. You can look at the discussions on it elsewhere, although I'd just dismiss it as slop.

    The standard library is mostly fine to use unless you have specific needs.

    The bit about libraries is nonsense, sorry.

You're right that C++ has a lot of features. But like mentioned elsewhere most projects define their own conventions and the subset of features that they use.

Also the nice thing about having a large set of features is that C,++ allows you to write very nice abstractions (or not) at both very low or at very high level. In other words you can be very low level with online ASM and bit operations and bit and direct memory manipulation or very high level almost like a script language. Whatever the problem domain needs C++ has got you covered.

One of my hobbies is rummaging around thrift stores appreciating tacky things from bygone eras, sifting through ill-conceived modern junk, and delighting in simple, solid tools where I can find them.

That's what it's like to be a C++ programmer.

I don't really understand this perspective. You don't need to memorize anything to learn a new programming language. You choose a medium-sized project you've already done in another language, start with "Hello world," and add one line of code at a time until the project is done. When there's something you need that you don't know how to do, you look it up.

You'll end up with a strong understanding of the subset of the language that's actually useful for the thing you want to build.

You can be pretty productive even with 70% of the language :) It is a common misconception that C++ is suitable only for game engines and similar domains. It is perfectly fine for applications domain as well.

As a side note, regarding your profile info, unless you are based in North Korea, please at least add one 0 to your rate. You'll get more long-term and high-quality clientele.

  • > You can be pretty productive even with 70% of the language

    Or even far less than that. I like to use it as C with lambdas and namespaces. Sprinkle in metaprogramming as needed. Even just not having to remember to call cleanup code thanks to dtors would alone be enough to sell me on it.

  • Only by people that started working in Web during the 2000's.

    Back in the 90's, it was the main business language alongside Smalltalk, Delphi and VB.

    Hence the plethora of C++ frameworks to chose from, sadly most dead since .NET and Java took over most of the use cases.

  • Honestly, I don't expect to find clients here. Fundamentally, you have to trust me to give me work. The amount of money doesn't really matter much to me.

> But if someone told me to write C++ myself, I'd cry. There's too much to memorize, and the standards are too varied

If someone tells you to write a web app, do you also cry? Surely there's more JavaScript frameworks than subsets of C++ at this point, no? Do you also go memorize all of them? Or do you just quickly pick one, and then only learn that one, and forget the rest exist? Because that's kinda how you approach C++. You pick a subset (like, say, just modern C++, only caring about C++17 & later or whatever), and just use that. And move on with your life. There's absolutely no reason to learn how std::auto_ptr works because it's dead in the same way you aren't learning how PHP & CGI works if you're making a modern web app. They're dead relics of the past that you can just pretend don't exist.

funny, I think the same about rust.

  • (Safe) Rust is a lot better about the "Pit of Success" design than C++

    There are fundamental technical choices to deliver that, but also ergonomic things like notice Rust's []::sort is a stable sort, whereas C++ std::sort is an unstable sort. If you don't know about sort stability in Rust what you wrote works and in C++ you get a nasty surprise.

    • C++ has std::sort() and std::stable_sort(). You should write what you mean, and you should know and understand your tools. Blaming the tool for your ignorance marks you as significantly less than an artisan.

      4 replies →

Not really, despite all its warts, it is exactly because of them that many reach out to C++.

Many of us don't like C, it was already too little and too unsafe, when the first C++ compilers started to hit the market in early 1990's, hence why all desktop OSes moved into C++ for their frameworks.

The return to C has caused by the rise of FOSS, UNIX winning the server room, and early GNU coding standards to use only C as main compiled language.

Additionally as many other programming language ecosystems have discovered, it is easy to beat C++ in version 1.0, and eventually all of them grow to get the complexity of their own.

I reach for C++, because the language runtimes, compiler tooling, and GPGPU frameworks I care about are partially written in C++, and I am not in the place to be writing new ecosystems myself.

  • I work maintaining the toolchain and language runtimes for a commercial safety-certified embedded operating system. I am deeply familiar with C and C++ because I live it and breathe it every day and have done so for over 40 years.

    Most of our customers use C, probably for historic reasons but also because it is much much easier to reason about and that becomes very important when auditing for functional safety certification. If someone's life depends on your software, you really want to be able to reason about its correctness because orange jumpsuits enhance no one's complexion.

    Many of customers are now using C++. From the problems they have reported, well, they just shouldn't. It's not that it is a bad language (it isn't) or that it is inherently unsafe (it really isn't: exceptions are safer than propagating return values as long as you use them in exception conditions, because not catching one will return you to a designed safe state very quickly, and RAII is the best thing since sliced cheese). It's that cutting and pasting from Stack Overflow, and now vibe coding, makes for massive codebases that are next to impossible to reason about. I now see a lot of problems from customers where my first reaction is "don't write code like that" and "you can write bad JavaScript code in any language, can't you?". While it butters my bread and I enjoy the language, I really recommend against using C++ for safety-certified embedded software. Stick to C.

    • If only C actually had fat pointers as Dennis Ritchie, one of the authors, proposed to WG14.

      It is quite relevant to note that the C authors, were keen to explore Alef as alternative on Plan 9, and based on the learnings reduced C's role on Inferno, and eventually took part in Go's design.

      Even though they were not keen into using C++ (Plan 9 doesn't even support it), they were also aware C wasn't to be used for everything.

    • > I really recommend against using C++ for safety-certified embedded software. Stick to C.

      You're almost certainly better off with Rust at this point or, if you must have C-like development, Zig.

  • The return to C was caused by other languages taking over every niche where C++ is better suited than C.

    There isn't even much of a "return" there. In fact, AFAIK, C++ expanded over C the entire time.

The language is fine, mostly, nowadays.

The ecosystem isn't fine - just to get a project going requires picking a non-trivial set of tools and approaches, none of which the C++ standard enforces or guides to.

For example, will you manage dependencies via packages? If so, with what? What will you use for building your project? The list goes on and on.

  • No it's not.

    The language keeps growing, with

    - new features overlapping old features from previous standards without replacing them or deprecating them (function::copyable_function vs std::function, std::less<> key for transparent lookup in maps)

    - new features not usable by the layman (coroutines ...)

    - Cryptic syntax (reflection...)

    - Stuff you are told not to use because of performance reason and that cant be fixed because of ABI (regex)

    - Compile errors that are 1km long (no, concepts are not helping here, the 'nicer' message is still buried into a hot pile of template instantiation callstack).

    • I wonder how many programming languages would be able to devoid of all or some of these problems when they are 40 years old.

      It's easy to compare new and old languages, and saying older languages are wrinkly. Let's see how other shiny programming languages look like when they are 40 years old.

      2 replies →

  • I personally find the lack of native package management in C++ as a blessing. Go, Python, Rust has it, and this always causes pulling in infinite number of packages for any trivial operation.

    sudo-rs was pulling in 1M+ LOC as its dependency chain at one point. I believe they removed the biggest offenders, but I didn't check it recently.

    • That's one way to look at it, certainly. There are several OK options in that space, e.g. Conan (2) and vcpkg.

>There's too much to memorize, and the standards are too varied. When I go to a project site for maintenance and it's a C++ project, I instantly lose energy — because it's just too difficult.

If you'd already been using it for 10+ years you wouldn't feel that way, because you'd already have memorized a lot of it.

  • Except the language keeps growing, with

    - new features overlapping old features previous standards without replacing them or deprecating them. - new features not usable by the layman - ...

    See function::copyable_function vs std::function, modules, coroutines, Reflection syntax is cryptic at best, ...

    • You don't have to use them. There's a handful of nice to haves in modern releases but its totally fine and sane to just ignore whatever the committee is distracted by at the moment.

      Hell, if you wait long enough, they'll just deprecate it before you can care to bother.

      2 replies →