News for hackers. Stuff that matters.
Re:C++26 Reflections adventures and compile time UML by matt123456789 on Saturday August 02, 2025 @10:55PM (#44773705)
Whenever I start to feel like a real programmer making games and webapps and AI-enhanced ETL pipelines, I inevitably come across the blog post of a C++ expert and reminded that I am basically playing with legos and play-doh.
Re:C++26 Reflections adventures and compile time UML by tw061023 on Saturday August 02, 2025 @11:29PM (#44773863)
It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software.

No way anything std::meta gets into serious production; too flexible in some ways, too inflexible in others, too much unpredictability, too high impact on compilation times - just like always with newer additions to the C++ standard. It takes one look at coding standards of real-world projects to see how irrelevant this stuff is.

And like always, the problem std::meta is purported to solve has been solved for years.

Re:C++26 Reflections adventures and compile time UML by d_tr on Sunday August 03, 2025 @12:00AM (#44773991)
What's the solution that's been around for years?

> ... just like always with newer additions to the C++ standard.

This is objectively laughable.

Re:C++26 Reflections adventures and compile time UML by jcranmer on Sunday August 03, 2025 @12:23AM (#44774065)
> What's the solution that's been around for years?

Build tools to generate C++ code from some other tool. Interface description languages, for example, or something like (going back decades here) lex and yacc even.

Re:C++26 Reflections adventures and compile time UML by d_tr on Sunday August 03, 2025 @12:56AM (#44774165)
Great. But you can do anything you want by generating code. Why not have a standard solution instead of everyone doing their own, possibly buggy thing complicating their build process even more?
Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @01:12AM (#44774221)
Reframe it as "you can do precisely what you need by generating code" and there is your answer.

Which is far better than to rely on a party which, as I said, has precisely nothing to do with what anyone needs. Which will inevitably produce solutions that can only partially (I am being generous here) be used in any particular situation.

As for "possibly buggy" - look, I can whip up a solid *DL parser complete with a C++ code generator in what, a week? And then polish it from that.

The committee will work for several years, settle on a barely working design, then it will take some years to land in major compilers, then it will turn out it is unusable because someone forgot a key API or it was unfeasible on VAX or something like that.

And my build process is not complicated, and never will be. It can always accomodate another step. Mainly because I don't use CMake.

Re:C++26 Reflections adventures and compile time UML by comex on Sunday August 03, 2025 @03:56AM (#44774925)
You can write a parser for an IDL, but you can’t reasonably write a parser for C++. So you have to move the definition of whatever types of methods or fields you want to reflect on into the IDL, instead of defining them natively in C++. (Or worse, have separate definitions in both the IDL and C++.) Which tends to be cumbersome – especially if you want to define a lot of generic types (since then the code generator can’t statically determine the full list of types). It can work, but there’s a reason I rarely see anyone using this approach.
Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @05:24AM (#44775298)
Why would I want to write a C++ parser?

IDL/DDL is the source of truth, moving the type definitions there is the whole point. There is only one definition for each type, which is in the *DL, corresponding C++ headers are generated and everything is statically known.

Re:C++26 Reflections adventures and compile time UML by birn559 on Sunday August 03, 2025 @01:40AM (#44774322)
My perception is that C++XY features are wildly used in general. Of course there are some nobody uses, but that's not generally true. So your basic assumption is wrong.

We are at C++20 and I wouldn't like to work for a company that uses an earlier standard.

Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @01:54AM (#44774387)
Well, either you carefully vet which C++ features you use and my assumption still stands, or you don't - in which case I would rather not like to work in your company.
Re:C++26 Reflections adventures and compile time UML by a_t48 on Sunday August 03, 2025 @05:47AM (#44775391)
I've been down this road. I ended up with a config YAML (basically - an IDL) that goes into a pile of jinja files and C++ templates - and it always ended up better and easier to read to minimize the amount of jinja (broken syntax highlighting, the fact that you are writing meta meta code, it's a hot mess). I'd much prefer to generate some bare structs with some minimal additional inline metadata than to generate both those structs and an entire separate set of structs describing the first ones. std::meta lets me do the former, the latter is what's possible right now.
Re:C++26 Reflections adventures and compile time UML by eschneider on Sunday August 03, 2025 @05:51AM (#44775417)
Debugging/modifying code generated from someone's undocumented c++ code generator is pretty close to the top of my list of unpleasant things to do. Yes, you can eventually figure out what to do by looking at the generated code and taking apart the code generator and figuring out how it all works but I'll take built-in language features any day.
Re:C++26 Reflections adventures and compile time UML by mpyne on Sunday August 03, 2025 @12:26AM (#44774082)
I was literally running into something a couple of days ago on my toy C++ project where basic compile-time reflection would have been nice to have for some sanity checking.

And even if it's true that some things can be done already with specific compilers and implementation-specific hacks, it would be really nice to be able to do those things more straightforwardly.

My experience with C++ changes has been that the recent additions to compile-time metaprogramming operations is that they improve compile times rather than make it worse, because you don't have to do things like std::enable_if<> hacks and recursive templates to do things that a simple generic lambda or constexpr conditional will do, which are more difficult for both you and the compiler.

Re:C++26 Reflections adventures and compile time UML by spacechild1 on Sunday August 03, 2025 @03:35AM (#44774845)
Constexpr if and fold expressions have been a god send!
Re:C++26 Reflections adventures and compile time UML by corysama on Sunday August 03, 2025 @01:33AM (#44774291)
The history of C++ has been one long loop of:

1. So many necessary common practices of C++ are far too complicated!

2. Std committee adds features to make those practices simpler.

3. C++ keeps adding features. It’s too big. They should cut out the old stuff!

4. The std committee points at the decade-long Python 3 fiasco.

5. Repeat.

Re:C++26 Reflections adventures and compile time UML by birn559 on Sunday August 03, 2025 @01:46AM (#44774353)
Do they point at python 3? They were committed to backward compatibility long before python3 happened.

To me it feels like they have fleshed out key paradigms so that is not a mess anymore. They are not there yet with compile time evaluation (constexpr consteval,...), at least with C++20, not sure if it's mostly finished with C++23/26.

The language itself and std is quite bloated but writing modern C++ isn't that complicated anymore in my experience.

Re:C++26 Reflections adventures and compile time UML by zozbot234 on Sunday August 03, 2025 @06:12AM (#44775497)
It's pure Stockholm syndome. There's even a nice C++ committee paper that summarizes this as "Remember the Vasa!" https://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0977r0...
Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @12:58AM (#44774171)
Whip up some kind of in-house IDL/DDL parser, codegen from that.

Which, precisely, additions do not fit my points?

Re:C++26 Reflections adventures and compile time UML by jandrewrogers on Sunday August 03, 2025 @01:24AM (#44774265)
Completely inadequate for many use cases. IDL/DDL is one of the least interesting things you could do with reflection in C++. You can already do a lot of that kind of thing with existing metaprogramming facilities.
Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @01:38AM (#44774315)
Which use cases? What exactly you can do with "existing metaprogramming facilities"?
Re:C++26 Reflections adventures and compile time UML by birn559 on Sunday August 03, 2025 @01:36AM (#44774308)
Most of the time, I will prefer standard C++ over a full hand made layer of complexity that needs maintenance.
Re:C++26 Reflections adventures and compile time UML by DLoupe on Sunday August 03, 2025 @03:15AM (#44774741)
For example, boost library's "describe" and similar macro based solutions. Been using this for many years.
Re:C++26 Reflections adventures and compile time UML by funkychicken on Sunday August 03, 2025 @12:23AM (#44774064)
I know the trading firm I work at will be making heavy use of reflection the second it lands… we had a literal party when it made it into the standard.
Re:C++26 Reflections adventures and compile time UML by mylons on Sunday August 03, 2025 @01:08AM (#44774206)
sure, but instagram was created by a handful of people with python and got a billion dollar exit in 2012.
Re:C++26 Reflections adventures and compile time UML by emmelaich on Sunday August 03, 2025 @03:23AM (#44774787)
And Youtube used Python almost exclusively at the start AFAIK.

Then again Scott Meyers said he's never written a C++ program professionally.

Re:C++26 Reflections adventures and compile time UML by motorest on Sunday August 03, 2025 @12:18PM (#44777591)
> Then again Scott Meyers said he's never written a C++ program professionally.

I think you're inadvertently misrepresenting Scott Meyers' claim.

Cited from somewhere else:

> I'll begin with what many of you will find an unredeemably damning confession: I have not written production software in over 20 years, and I have never written production software in C++. Nope, not ever.

He went on to clarify that he made a living out of consultancy, not writing software. He famously retired from C++ in 2015, too.

Re:C++26 Reflections adventures and compile time UML by birn559 on Sunday August 03, 2025 @01:31AM (#44774287)
What has that to do with the topic? Warren Buffet made billions without any do knowledge about programming or deeper knowledge about computers.
Re:C++26 Reflections adventures and compile time UML by mikrl on Sunday August 03, 2025 @01:02PM (#44777984)
Mansa Musa was so rich he decreased the local gold to silver exchange rate in Egypt by 12% without ANY modern technology!

https://en.wikipedia.org/wiki/Mansa_Musa#Wealth

Re:C++26 Reflections adventures and compile time UML by ozgrakkurt on Sunday August 03, 2025 @06:01AM (#44775462)
What is this culture of judging everything by amount of money.

No one needs a billion dollars, it is practically irrelevant unless you are running on greed

Re:C++26 Reflections adventures and compile time UML by mylons on Sunday August 03, 2025 @12:01PM (#44777465)
money is a proxy for value. the post i was responding to seemed to be pointing out how little value there is in something else.
Re:C++26 Reflections adventures and compile time UML by d_tr on Monday August 04, 2025 @12:15AM (#44782071)
The post you responded to said they were very happy about their tools becoming better and your reply read as a dismissal of that, citing someone having made billions by writing an advertisement platform in Python.

So either I and others misread you or it is just a matter of different views on value.

Re:C++26 Reflections adventures and compile time UML by motorest on Sunday August 03, 2025 @12:06PM (#44777503)
> sure, but instagram was created by a handful of people with python and got a billion dollar exit in 2012.

Facebook famously felt compelled to hire eminent C++ experts to help them migrate away from their PHP backend. I still recall reading posts on the Instagram Engineering blog on how and where they used C++.

Re:C++26 Reflections adventures and compile time UML by pjmlp on Monday August 04, 2025 @01:24AM (#44782356)
And then HipHop failed to provide as much gains as they hoped for versus the Hack JIT implementation, thus Facebook keeps writing mostly PHP like code in many of their workloads.
Re:C++26 Reflections adventures and compile time UML by motorest on Monday August 04, 2025 @01:57AM (#44782502)
> And then HipHop failed to provide as much gains as they hoped (...)

What point do you think you're making?

Re:C++26 Reflections adventures and compile time UML by pjmlp on Monday August 04, 2025 @02:08AM (#44782547)
That the C++ migration in the end did not achieve everything they were trying to get out of it, and another more productive approach was chosen in the end.

https://en.wikipedia.org/wiki/HipHop_for_PHP

https://en.wikipedia.org/wiki/HHVM

Re:C++26 Reflections adventures and compile time UML by jandrewrogers on Sunday August 03, 2025 @01:16AM (#44774239)
The stream of modern C++ features have been a god-send for anyone that cares about high-performance, high-reliability software. Maybe that doesn’t apply to your use case but C++ is widely used in critical data infrastructure. For anyone that does care about things like performance and reliability, the changes to modern C++ have largely been obvious and immediately useful improvements. Almost all C++ projects I know in the high-performance data infrastructure space live as close to the bleeding edge of new C++ features as the compiler implementations make feasible.

And no, reflection hasn’t “been solved for years” unless you have a very misleading definition of “solved”. A lot of the C++ code I work with is heavily codegen-ed via metaprogramming. Despite the relative expressiveness and flexibility of C++ metaprogramming, proper reflection will dramatically improve what is practical in a strict and type-safe way at compile-time.

Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @01:34AM (#44774301)
I am sorry, but this reads like GPT.

Which projects? Which features? What exactly was the impact on performance and reliability, how and why? How did critical projects adopt the stream of features, considering nobody sane touches nothing in a new C++ standard for a decade, waiting for DRs to settle and for codegen stopping to suck?

Reflection has been solved for years with custom codegen, including dimensions which std::meta cannot even touch such as stable cross-platform, cross-compiler ABI.

Re:C++26 Reflections adventures and compile time UML by William_BB on Sunday August 03, 2025 @05:37AM (#44775343)
You sound like you subscribe to "Orthodox C++".

Speaking seriously, I agree there's definitely a lot of bloat in the new C++ standards. E.g. I'm not a fan of the C++26 linalg stuff. But most performance-focused trading firms still use the latest standard with the latest compiler. Just a small example of new C++ features that are used every day in those firms:

Smart pointers (C++11), Constexpr and consteval (all improvements since C++11), Concepts (C++20), Spans (C++20), Optional (C++17), String views (C++17)

Re:C++26 Reflections adventures and compile time UML by motorest on Sunday August 03, 2025 @02:46PM (#44778719)
> I'm not a fan of the C++26 linalg stuff.

I don't agree at all. For most, linear algebra is the primary reason they pick up C++. Up until now, the best option C++ newbies had was to go through arcane processes to onboard a high performance BLAS implementation which then requires even more arcane steps such as tuning.

With C++26, anyone can simply jump into implementing algorithms.

If anything, BLAS support was conspicuously missing from C++ (and also C).

This blend of comments is more perplexing given that a frequent criticism of C++ is its spartan standard lib, and how the selling point of some commercial software projects such as Matlab is that, unlike C++, linear algebra work is trivial.

Re:C++26 Reflections adventures and compile time UML by pjmlp on Monday August 04, 2025 @01:22AM (#44782341)
Except the devil is in the details as usual, the way linalg is specified doesn't guarantee numeric stability across library implementations or compilers.

Just like the std::random mess, most people are in for a surprise when they attempt to write portable numeric code with it.

Re:C++26 Reflections adventures and compile time UML by motorest on Monday August 04, 2025 @01:42AM (#44782450)
> Except the devil is in the details as usual, the way linalg is specified doesn't guarantee numeric stability across library implementations or compilers.

I think this criticism is silly. You're complaining about the C++ standard not enforcing something that is virtually impossible and no implementation under the sun even suggests it would conceivably support. And we should just assume C++ would be able to force it across implementations, target platforms, and even architectures? Ridiculous.

> Just like the std::random mess (...)

The comments I've seen regarding std::random mainly refer to gotchas, such as std::rand returning values in [0, RAND_MAX] and the latter being a platform-specific constant.

There is a reason after all why you only throw vague complains of "mess" instead of pointing out specific concerns or grievances. You need to complain, regardless of merit.

Overall, this blend of criticism is no different than the cliche criticism targeting the STL. Sure, some niche applications can and do have better ways to scratch their niche itches. In the meantime the STL perfectly serves the need of 99.9% of all common usages. Is this not the point? Doesn't linalg and rand achieve this?

Of course vapid nitpickers can still pull out the last resort card of complaining that the implementation is too complicated, a grievance also directed at the STL. But that's just the extent where this silliness goes.

Re:C++26 Reflections adventures and compile time UML by pjmlp on Monday August 04, 2025 @02:11AM (#44782556)
Not silly at all, if it can't be enforced in a standard portable way, its place doesn't belong in the standard, at all.

I would have voted SA on this matter, if I had a life that would allow me to go around voting at WG21 meetings.

We have vcpkg and conan now, the standard library cannot be a distribution vehicle for organisations that refuse to adopt C++ package managers.

Re:C++26 Reflections adventures and compile time UML by account42 on Monday August 04, 2025 @09:22AM (#44785412)
> This blend of comments is more perplexing given that a frequent criticism of C++ is its spartan standard lib

The frequency doesn't make the criticism more valid and those repeating it would be better served to let go of their fear of third-party libraries.

Re:C++26 Reflections adventures and compile time UML by motorest on Tuesday August 05, 2025 @02:22AM (#44794858)
> The frequency doesn't make the criticism more valid (...)

The criticism is not valid. It's specious reasoning at best, fueled by a hefty dose of gatekeeing.

The only rationale that is relevant is whether the standard library provides a way to do a very basic and fundamental task instead of having to force anyone to onboard and manage third party dependencies. That's the whole point of a standard library, isn't it?

Re:C++26 Reflections adventures and compile time UML by account42 on Tuesday August 05, 2025 @03:28AM (#44795264)
No the point of a standard library is to provide vocabulary types (so that third-party libraries can interoperate) as well as basic operations that are essentially set in stone. Anything beyond that needs to have its usefulness weighted against its maintenance burden, which for a standard library that is serious about backwards compatibility is enormous. C++ is already also heavily criticized for being complex with many problems having multiple outdated solutions that you're not supposed to use.

"Onboarding" a third party library isn't this herculean task that you make it out to be but is in fact a very basic part of software development that almost any project will have to deal with anyway unless you are into reinventing the wheel - even excessively bloated standard libraries don't manage to cover everything.

Re:C++26 Reflections adventures and compile time UML by jcelerier on Monday August 04, 2025 @10:51AM (#44786633)
> I don't agree at all. For most, linear algebra is the primary reason they pick up C++.

Out of hundreds of hundreds of projects I've interacted with, maybe less than 1% have used linear algebra in any non-basic capacity (e.g. more than multiplying two 4x4 matrices) and had to use Eigen or BLAS

Re:C++26 Reflections adventures and compile time UML by motorest on Tuesday August 05, 2025 @02:18AM (#44794841)
> Out of hundreds of hundreds of projects I've interacted with, maybe less than 1% have used linear algebra in any non-basic capacity (e.g. more than multiplying two 4x4 matrices)

Are you really trying to argue that if you ignore the bulk of applications that have linear algebra then only a few have linear algebra?

> and had to use Eigen or BLAS

What if I told you that if C++ provided basic support for linalg, your average C++ developer wouldn't ever have to hear about Eigen or blas?

It's perfectly fine if you want to use the likes of Eigen. It's also perfectly fine if any developer opts to ditch the STL and use any performance-oriented container.

But is it ok to force everyone to onboard a third party library just to be able to do very basic things like use a stack or do a dense matrix-vector multiplication? I don't think that leads to a good developer experience.

Re:C++26 Reflections adventures and compile time UML by SleepyMyroslav on Sunday August 03, 2025 @05:38AM (#44775350)
You are sounding like rose tinted glasses are on. I think your glass is half full if you recheck actual versions and features. And mine is half empty in gamedev.

Anecdata: A year or so ago I have been in discussion if beta features of C++20 on platforms are good to be used on large scale. It makes it not a sum but an intersection of partial implementations. Anyway it looked positive until we needed a pilot project to try. One of the projects came back with 'just flipping C++20 switch with no changes causes significant regression on build times'. After confirming it that it is indeed not an error on our side it was kinda obvious. Proportional increase of remote compilation cloud costs for few minor features is a 'no'. After a year the beta support is no longer beta but still partial on platforms and no improvements on build times in community. YMMV of course because gamedev mostly supports closed source platforms with closed set of build tools.

Re:C++26 Reflections adventures and compile time UML by Someone on Sunday August 03, 2025 @09:19AM (#44776393)
> One of the projects came back with 'just flipping C++20 switch with no changes causes significant regression on build times

Given that C++20 introduced modules, which are intended to make builds faster, I think just flipping C++20 switch with no changes and checking build times should not be the end of checking whether C++20 is worth it for your setup.

Re:C++26 Reflections adventures and compile time UML by jcranmer on Sunday August 03, 2025 @10:17AM (#44776747)
> Given that C++20 introduced modules, which are intended to make builds faster

Turning on modules effectively requires that all of your project dependencies themselves have turned on modules. Fail to do so, and a lot of the benefits start to become hindrances (Clang is currently debating going to 64-bit source locations because modularizing in this manner tends to exhaust the current 32-bit source locations).

Re:C++26 Reflections adventures and compile time UML by motorest on Sunday August 03, 2025 @12:01PM (#44777463)
> One of the projects came back with 'just flipping C++20 switch with no changes causes significant regression on build times'.

I think this just proves that your team is highly inexperienced in C++ projects, which you implicitly attest by admitting this was your first C++ upgrade you had to go through.

Let me be very clear: there is never an upgrade of the C++ version targeted by a project that does not require full regression tests and a few bugs to squash. Why? Because even if the C++ side of things is perfectly fine, libraries often introduce all sorts of unexpected issues.

For example, once I had to migrate a legacy project to C++14 and flipping the compiler flag to c++14 caused a wall of compiler errors. It turned out the C++ was perfectly fine, but a single library behaved very poorly with a constexpr constructor they enabled conditionally with C++14.

You should understand that upgrades to the core language and standard libraries are exceptionally stable, and a clear focus of the standardization committee. But they only have a say in how the core language and standard libs should be. The bulk of the code any relatively complex project consumes is not core lang+ stdlib, but third-party libraries and frameworks. These often are riddled with flags to toggle whole components only in specific versions of the C++ language, mainly for backwards compatibility. Once you target a new version of C++, often that means you replace whole components of upstream dependencies. This often requires fixing your code. This happens very frequently, even with the likes of Boost.

So, what you're complaining about is not C++ but your inexperience in software engineering in general. I mean, what is the rule of thumb about major version upgrades?

Re:C++26 Reflections adventures and compile time UML by SleepyMyroslav on Sunday August 03, 2025 @02:10PM (#44778447)
I am sorry for the confusion. It's fine to have some downvotes if its not what ppl like to see. I was not complaining. Message was purely informational from single point of view that a) game platforms have only partial C++20 support in 2025. b) there are features that are in C++ standard that do not fit description 'god-send'.
Re:C++26 Reflections adventures and compile time UML by account42 on Monday August 04, 2025 @09:16AM (#44785331)
> Proportional increase of remote compilation cloud costs for few minor features is a 'no'.

How high are those compilation costs compared the developer time that might be saved with even minor features?

Re:C++26 Reflections adventures and compile time UML by SleepyMyroslav on Monday August 04, 2025 @05:28PM (#44791565)
Tbh I dont have exact numbers from 2024 at hand. I remember that decision was unanimous. A build times increase is a very sensitive topic for us in gamedev.
Re:C++26 Reflections adventures and compile time UML by PartiallyTyped on Sunday August 03, 2025 @01:05PM (#44778001)
I am interested; could you provide some links, articles, etc?
Re:C++26 Reflections adventures and compile time UML by MathMonkeyMan on Sunday August 03, 2025 @02:21PM (#44778521)
I still have to learn C++20 concepts and now we have a full-fledged reflection system?

Good, but I think what happens is there are people on the bleeding edge of C++, usually writing libraries that ship with new code. Each new feature is a godsend for them -- it's the reason why the features are proposed in the first place. It allows you to write libraries more simply, more generally, more safely, and more efficiently.

The rest of us are dealing with old code that is a hodgepodge of older standards and toolchains, that has to run in multiple environments, mostly old ones. It's like yeah, this C++26 feature will come in handy for me someday, but if that day comes then it will be in 2036, and I might not be writing C++ by then.

Re:C++26 Reflections adventures and compile time UML by Ballas on Monday August 04, 2025 @01:39AM (#44782441)
>The rest of us are dealing with old code that is a hodgepodge of older standards and toolchains, that has to run in multiple environments, mostly old ones. It's like yeah, this C++26 feature will come in handy for me someday, but if that day comes then it will be in 2036, and I might not be writing C++ by then.

Things seem to be catching up. I had the same view up until recently, but now I'm able to use most of the C++23 features in an embedded platform (granted, some are still missing (limited to GCC 11.2).

Re:C++26 Reflections adventures and compile time UML by throwaway9832 on Sunday August 03, 2025 @02:10AM (#44774447)
Every problem is solved. We should stop making anything. Specially CRUD apps, because how is that even programming? What does it solve that hasn't been solved?

This line of thinking is not productive. It is a mistake to see yourself as what you do, because then you're cornering yourself into defending it, no matter what.

Re:C++26 Reflections adventures and compile time UML by pjmlp on Sunday August 03, 2025 @02:36AM (#44774560)
I bet CERN might eventually replace their Python based code generators with C++26 reflection.
Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @03:37AM (#44774849)
Which problem would this solve for them?
Re:C++26 Reflections adventures and compile time UML by dguest on Sunday August 03, 2025 @04:05AM (#44774964)
It would standardize something they've done with a home-brewed tool for decades. They have a library called "reflex" [1] which adds some reflection, and which was (re)written by cannibalizing a lot of llvm code. They actually use the reflection to serialize a lot of the LHC data.

It's kind of neat that it works. It's also can be a bit fidgety: the cannibalized code can cause some issues (which, e.g. prevented C++11 adoption for a while in some experiments), and now CERN depends on bits of an old C++ compiler to read their data. Some may question the wisdom of making a multi-billion dollar dataset depend on the internals of a C++ compiler, but for sure having a standard is better than the ad-hoc solution they rely on now.

[1]: https://indico.cern.ch/event/408139/contributions/979831/att...

Re:C++26 Reflections adventures and compile time UML by oyoman on Sunday August 03, 2025 @05:12AM (#44775248)
The library that you refer is not in use for a long time already. The document you pointed out is from 2006 (you can check the creation date).

Since then, a lot has changed, and now it is all based on cling ( https://root.cern/cling/ ), that originates from clang and llvm. cling is responsible generates the serialization / reflection of the classes needed within the ROOT framework.

Re:C++26 Reflections adventures and compile time UML by dguest on Sunday August 03, 2025 @08:38AM (#44776141)
Good catch: I'm confusing reflex and the cling code that came later. All the issues I mentioned are still there in (or caused by) cling though. Either way standardization in reflection would help.
Re:C++26 Reflections adventures and compile time UML by pjmlp on Sunday August 03, 2025 @04:02AM (#44774954)
Two language problem, kind of well known issue in engineering tradeoffs.
Re:C++26 Reflections adventures and compile time UML by Culonavirus on Sunday August 03, 2025 @04:44AM (#44775115)
As an example, most of the big js/ts ecosystem expansion to the server (RSC/Next/RR7/Expo/...) over the last few years is driven by the wish to have everything under one roof and one language.

People just don't want to maintain two completely different stacks (one on the server, one on the client).

Re:C++26 Reflections adventures and compile time UML by otabdeveloper4 on Sunday August 03, 2025 @03:43AM (#44774879)
Yeah, wait till you find out what's behind the curtain in your web engine and AI.

Hint: it's C++, and yes, it will eventually use stuff like std::meta heavily.

Re:C++26 Reflections adventures and compile time UML by tw061023 on Sunday August 03, 2025 @03:48AM (#44774897)
If you would check my comments, you would see I am quite aware. And no, it will not, just like it was with streams, ranges and whatever else.
Re:C++26 Reflections adventures and compile time UML by zozbot234 on Sunday August 03, 2025 @04:48AM (#44775132)
> No way anything std::meta gets into serious production

Rust proc macros get used in serious production, even though they're quite slow to compile. Sure, std::meta is probably a bit clunkier, but that's expected from new C++ features as you say.

Re:C++26 Reflections adventures and compile time UML by Thom2000 on Sunday August 03, 2025 @09:52AM (#44776596)
Sadly, Rust proc macros operate on tokens and any serious macro implementation needs third-party crates.

Compile-time reflection, with good, built in API, akin to C# Roslyn would be a real boon.

Re:C++26 Reflections adventures and compile time UML by galangalalgol on Sunday August 03, 2025 @10:03AM (#44776669)
Any serious anything needs third party crates. Coming from c++ this has been the most uncomfortable aspect of rust to me, but I am acclimating.
Re:C++26 Reflections adventures and compile time UML by a_t48 on Sunday August 03, 2025 @05:39AM (#44775355)
Prediction: it will be used heavily for things like command line arg parsing, configuration files, deserialization, reflection into other languages. It will probably be somewhat a pain to use, but better than the current alternative mashup of macros/codegen/template metaprogramming that we have now for some of these solutions. It will likely mostly be used for library code, where someone defines some nice utilities for you, that do something useful, so that you don't have to worry about it. I don't think for the most part it has to hurt compile times - it might even be faster than the current mess, as well - less use of templates.

I don't think the "legos" vs "shipping" debate here is really valid. One can write any type of code in any language. I'm a freak about C++, but if someone wants to ship in Python or JS, the more power to them - one can write code that's fast enough to not matter, but takes advantage of those languages' special features.

Re:C++26 Reflections adventures and compile time UML by germandiago on Sunday August 03, 2025 @09:14AM (#44776361)
I embrace Modern C++, but slower than the committee, when the big three have the feature.

I really think reflection + annotations will give us the chance to have much better serialization and probably something more similar to Python decorators.

That will be plenty useful and it is going to transform a part of C++ ecosystem, for example I am thinking of editors that need to reflect on data structures or web frameworks such as Crow or Drogon, Database access libraries...

Re:C++26 Reflections adventures and compile time UML by adev_ on Sunday August 03, 2025 @11:11AM (#44777102)
> And like always, the problem std::meta is purported to solve has been solved for years.

It is rare to read something more moronic than that

The Rust equivalent of std::meta (procedural macros) are heavily used everywhere including in serialization framework, debugging and tracers.

And that's not surprising at all: Compile time introspection is much more powerful and lightweight than codegen for exactly the same usage.

Re:C++26 Reflections adventures and compile time UML by dwroberts on Sunday August 03, 2025 @11:26AM (#44777229)
> It is rare to read something more moronic than that

It's not actually wrong though is it - real codebases have been implementing reflection and introspection through macro magic etc. for decades at this point.

I guess it's cool they want to fix it in the language, but as always, the approach is to make the language even more complex than it already is - e.g. two new operators (!) in the linked article

Re:C++26 Reflections adventures and compile time UML by adev_ on Sunday August 03, 2025 @12:43PM (#44777821)
> been implementing reflection and introspection through macro magic etc. for decades at this point.

Having a flaky pile of junk as an alternative is never been an excuse to not fix the problem properly.

Every proper modern language (Rust, Kotlin, Zig, Swift, even freaking Golang) has a form of runtime reflection or static introspection.

Only C++ does not. It was done historically with a mess of macros or a pre-compiler (qt-moc) that all have an entire pile of issue.

> the approach is to make the language even more complex than it already is - e.g. two new operators

The problem of rampant complexity in C++ is not so much about the new features when they bring something and make sense.

It is about its inability to remove the old stuff even if it is consensual that it is garbage (e.g iostreams).

Re:C++26 Reflections adventures and compile time UML by d_tr on Monday August 04, 2025 @12:27AM (#44782123)
> Having a flaky pile of junk as an alternative is never been an excuse to not fix the problem properly.

Thank you. Some people use the phrases "real projects" and "production code" as if they imply some standard of high quality.

Re:C++26 Reflections adventures and compile time UML by motorest on Sunday August 03, 2025 @11:36AM (#44777287)
> It's the other way around. You are the real programmer and the committee and the "modern C++" crowd are more interested playing with legos instead of shipping actual software.

I think this is the most clueless comment I ever read in HN. I hope the site is not being hit with it's blend of September.

I was going to explain to you how fundamentally wrong your comment was, but it's better to just kindly ask you to post in Reddit instead.

Re:C++26 Reflections adventures and compile time UML by nickysielicki on Sunday August 03, 2025 @01:23PM (#44778127)
> the problem std::meta is purported to solve has been solved for years.

What solution is that? A Python script that spits out C++ code?

Re:C++26 Reflections adventures and compile time UML by lmariscal on Saturday August 02, 2025 @10:59PM (#44773722)
I would argue that C++ expertise doesn't necessarily correlate to the complexity of the software being developed. Although I do try to learn the fancy new features I know many developers who even though they are still only using C++11 features they are creating some very complex and impactful pieces of software.
Re:C++26 Reflections adventures and compile time UML by lanyard-textile on Sunday August 03, 2025 @01:10AM (#44774212)
I definitely think that’s not a coincidence. C++11 is where you get the most useful feature tradeoffs with reasonable costs.

Smart pointers being a great example. Shared ptr has its issues, it isn’t the most performant choice in most cases, but it by far reduces more footguns than it introduces.

Compared to something like std::variant in the C++17 standard that comes with poor enough performance issues that it’s rarely ever a good fit.

Re:C++26 Reflections adventures and compile time UML by jandrewrogers on Sunday August 03, 2025 @03:55AM (#44774924)
C++11 was for me the first version of C++ where the expressiveness justified the extra complexity relative to C. It was when I finally committed to using C++ instead of C for systems code. In the same sense, C++20 is qualitatively better than C++11 in every way and dramatically reduces the complexity of C++11 while adding many features C++11 needed.
Re:C++26 Reflections adventures and compile time UML by pjmlp on Monday August 04, 2025 @01:30AM (#44782383)
I would add C++23, but only due to std being available as modules, and at least on VC++ is kind of ok for side projects.
Re:C++26 Reflections adventures and compile time UML by otabdeveloper4 on Sunday August 03, 2025 @03:45AM (#44774886)
Just because someone didn't bother to learn anything past C++11 doesn't mean C++11 is some sort of performance sweet spot.
Re:C++26 Reflections adventures and compile time UML by tombert on Saturday August 02, 2025 @10:59PM (#44773721)
I'm not a C++ developer at all, but unless I'm missing something this didn't seem terribly difficult?

This isn't meant to make myself seem smart or to try and make you seem dumb, I'm just curious what was confusing about this even from a high-level perspective. It felt like a clever but not too atypical metaprogramming thing.

Maybe I've just done too much Clojure.

Re:C++26 Reflections adventures and compile time UML by rramadass on Sunday August 03, 2025 @12:39AM (#44774123)
I know your comment was meant as a tongue in cheek funny one but people should not be intimidated/overawed by the size of the C++ feature set. You don't need to know nor use all of them but can pick and choose based on your needs and how you model your problem. Also much of the complexity is perceived rather than real since it takes time for one to understand and assimilate new concepts. You can program very effectively and productively using just C++98 features (along with C if needed) with no hint of "Modern C++" (never mind the fanbois :-) What this gives you is the ability to use a single language to tackle small constrained microcontrollers with very limited toolchain support all the way to using the latest and the greatest toolchain on top-of-line processors.
Re:C++26 Reflections adventures and compile time UML by einpoklum on Sunday August 03, 2025 @07:23AM (#44775802)
Much of the complexity may be perceived, but much is also real, because of the commitment to backwards compatibility and non-breakage, plus poor default behavior of many things, often due to the C legacy, sometimes due to inopportune choices in earlier versions of the standard. Just think of things like variable initialization with () and/or {} ; or various kinds of implicit casts ; the hoops you need to go through to work with variants; etc.

But I agree that one doesn't have to learn everything, or nearly-everything, to write decent-to-good modern-C++ code.

Re:C++26 Reflections adventures and compile time UML by rramadass on Sunday August 03, 2025 @10:41AM (#44776884)
The problem is that many confuse C++ Language expertise (often snarkily called a "language lawyer") with C++ Programming expertise. A famous example is Scott Meyers who is squarely in the first camp and who has publicly stated as not having written any sizeable C++ programs. Given that C++ is quite a baroque language it is important for programmers to focus on the second aspect and slowly build up their knowledge of the first aspect over time (most experienced programmers tend to do this in any language).
Re:C++26 Reflections adventures and compile time UML by einpoklum on Monday August 04, 2025 @05:48PM (#44791734)
As a person who has some of both, I'm not so sure I agree. Many developers just get into the habit of assuming they don't need any more language knowledge, since they get by already, and the codebase they use is filled with code which fails to utilize most modern language features, and _that_ is already quite a hassle to know well enough to use.
Re:C++26 Reflections adventures and compile time UML by rramadass on Tuesday August 05, 2025 @11:37AM (#44799415)
Information and knowledge can be had at any age but it takes experience over time to gain wisdom. It is not that experienced developers are reluctant to learn new things but are cautious and conservative when it comes to adopting and putting them into practice especially for non-trivial systems in production. They have already tamed the complexity of their system and devised workable solutions to thorny problems and hence do not deem it wise to rewrite everything just because of some new fad and/or exciting feature being introduced in their language of use.

The fact that C++ is a multi-layered language with assured backwards compatibility really helps in slowly migrating to newer design paradigms and performant techniques while being sure/stable every step of the way.

Re:C++26 Reflections adventures and compile time UML by mkoubaa on Sunday August 03, 2025 @08:04AM (#44775965)
Library development and application development are activities of a different kind entirely.
Re:C++26 Reflections adventures and compile time UML by burnt-resistor on Wednesday August 06, 2025 @06:28AM (#44810198)
That's pretty advanced. I realize now I've been finger-painting on the non-washable walls all along. I will now sit in the corner with a dunce cap and consider an execution model for each of greedy and lazy functional languages.