Live data from Hacker News

C++: The Documentary

herbsutter.com

301–310 of 334 posts

Re: C++: The Documentary

#301
post #71

Earlier quoted context omitted.

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 stand…

What type of project actually uses C++ 23 modules in real life? What kind of toolchain enables that? When I worked on Chromium, they were indefinitely in the "maybe in 5-10 years the tooling will be ready" camp.

Projects: https://arewemodulesyet.org/projects/

Tools: https://arewemodulesyet.org/tools/

Re: C++: The Documentary

#303
post #2

Since I've been working in C++ a lot recently I decided to watch the video as I waited for a build to complete. So the length is about right. And fortunately, the video is a delight!

Wow is this just a shitpost (it was funny!) or do your builds actually take about an hour? That's nuts, if so.

Yes, although in all honesty the actual compilation is somewhat small compared to the many layers of unit, simulation, integration, and regression tests. All those corner cases take a long time to explore.

Re: C++: The Documentary

#305

Earlier quoted context omitted.

What operations could such frozen vector offer that std::vector does not? If there are none, it doesn't need a separate data structure.

The reason I'd want "frozen-size vector" is to replace pairs of data members of the form `T* foos; size_t foos_len;` without paying another 8 bytes to store a useless capacity that's never going to change. But I don't think that makes such a container worth adding to the STL. So far, it hasn't even been worth writing in our own code. But that's the reason I've thought about writing it.

This is how I designed my vector in C. Note it is still not frozen as you can use realloc just fine (even with good performance) and/or external tracking of the capacity in tight loops.

https://uecker.codeberg.page/2025-07-20.html

I probably will still add a version with capacity, because people may insist on it, but personally I like the one without much more so far.

Re: C++: The Documentary

#306
post #168

Earlier quoted context omitted.

I start counting from Python 1.

Well if c++ had the liberty of scrapping the language twice in the last 30 years I'm sure it would look better too.

Python 2 to 3 mess is exactly why all languages think twice about breaking backwards compatibility.

Re: C++: The Documentary

#307

Earlier quoted context omitted.

I tend to think of the web and the internet as distinct things. For the language of the web I'd probably nominate HTML. For the language of the internet it's a lot less clear to me.

Many browser rendering engines are built in C++, so C++ is parsing the HTML. My general point is that many web/internet techs that web devs interact with have C++ one abstraction level below for actual implementation.

All widely used HTML engines are C++. Of the up and coming ones, Servo is Rust and Ladybird is C++ potentially moving to Rust.

In any case, Rust is basically C++ 2.0 to me because it is very much in the spirit of C++.

Re: C++: The Documentary

#308

Earlier quoted context omitted.

Who cares if it crashes? The users. We can all agree it's not medical systems, but audio DSP and game dev both end up rewriting a lot of STL stuff to suit their needs, and often using a restricted subset of modern C++ features for similar reasons. That isn't some arbitrary choice, but pretty much where everyone continually ends up when solving real-time problems using C++. Whether those be games or not.

You can prevent more than enough crashes with enough testing to make gamers happy. Even if you prove there is not out of bounds error I still want a medical device to check

Even with an extreme high level of inhouse testing (which is needed anyway) you'll never find the bugs that are discovered when a hundred-thousand gamers try to exploit every little feature of your game.

The reason to keep asserts in release mode is so that when one of those asserts is triggered "out in the wild" the bug investigation is dramatically simplified. The assert message and callstack is usually enough to figure out what went wrong. With a regular crash that happens without asserts the actual reason of the crash may already be obfuscated enough that a useful bug diagnosis is no longer possible. E.g. an assert is usually triggered very close to the bug, while crashes are usually only the end result of a whole cascade of events triggered by an initial bug.

Re: C++: The Documentary

#309
post #182

Earlier quoted context omitted.

What early adopters are using them? Because my impression is the tooling still isn’t there

People using Visual C++ with MSBuild, or clang with CMake and ninja.

It’s been 6 months but last time I checked neither IntelliSense nor clangd worked with modules. The build tools have been just about functional for a while though, you’re right.

Re: C++: The Documentary

#310

Earlier quoted context omitted.

CMake has support for named modules but does not support header units or C++23 module features such as import std;

Import std has been there for a while but is experimental until gcc supports it. Gcc just for that support so it should be mainline soon.

We are now getting close to the distance between c++03 and C++11 for making basic modules work on main line toolchains and build systems. That’s absolutely wild.
Post reply on HN