C++26: Span improvements
7 points by raymii
7 points by raymii
C++ is so ridiculous. People constantly post about a plethora of exciting new features of a language that apparently nobody comprehended even 10 years ago. I recall even Matt Godbolt, who is like a super expert on C++ and has been using it for decades for all I know, saying in his Podcast that he is occasionally surprised when reading the standard. Maybe it was someone else, but it was definitely a C++ expert.
And, no, saying people either complain about a language or don’t use it is not an argument because it doesn’t address any of the concrete problems of C++. It’s just denying responsibility for poor design choices that cannot be changed now.
C++ is in a really tough spot because they can’t deprecate or remove existing features (too much code depends on them), but they want to address new demands. They also can’t make new versions incompatible with old ones because there’s lots of C++ mixing features from various standards.
C is aging much more gracefully because newer standards don’t aspire to beat, say, Zig. Maybe C++ should do the same.
C++ is in a really tough spot because they can’t deprecate or remove existing features (too much code depends on them), but they want to address new demands. They also can’t make new versions incompatible with old ones because there’s lots of C++ mixing features from various standards.
I'm glad that you included this empathetic point, since it's a lot more productive than the typical complaining. A lot of C++ folks don't want C++ to just give up and die, so they keep pushing C++ onward. However, C++ is like a katamari ball, getting bigger and bigger. Given that C++ is the de facto standard for entire industries, like game dev, what is there to do?
If C++ can't evolve, we would need a migration path away from it. I suspect that's a tougher pill to swallow, in the short/mid term, so people just stick with C++.
JavaScript has the same limitations, but JavaScript of 2026 is genuinely a much much better language than JavaScript of 2010. Yes, there are still footguns like ==, but you can feasibly avoid most of The Bad Parts and write moderately robust code. Why can’t C++ do this too?
C is aging much more gracefully because newer standards don’t aspire to beat, say, Zig. Maybe C++ should do the same.
That aging gracefully means “does not intent to meaningfully improve while it fades out of relevance”. Maybe C++ will fade away as well (I like a lot of C++ but the core semantics means it’s unlikely to ever be able to provide the same safety semantics as newer languages).
But that’s also ignoring existing code bases. If fixing existing problems requires complete rewrites then C projects are stuck: the only way to get meaningful safety improvements is a new language or extensions like -bonds-safety, which don’t require rewriting but still require a moderately significant amount of work for the annotations.
Meanwhile C++ (in addition to new library features - not language changes), does permit addressing a bunch of these problems relatively transparently, so you can improve the safety of your current code without requiring significant rewrites. E.g it is possible to incrementally fix/harden code.
Similarly I know of numerous C projects that switched to compiling with C++ so lifetime management could be automated in a way that simply is not possible in C.
And finally: this post is literally just minor additions to the span class to improve quality of life and generic compatibility with other container types, now that (C++ only) warnings like -Wunsafe-buffer-usage increased the use of span, so people realised these gaps actually matter. There are no language changes here, complains about these would be like complaining about the addition of new functions to the C standard.