News for hackers. Stuff that matters.
Re:Fun with C++26 reflection: Keyword Arguments by weinzierl on Tuesday February 11, 2025 @02:37AM (#43010053)
The article is about compile-time reflection, which is not nearly as useful as what the Wikipedia article you linked is about. It's only upside is that it is "zero cost" by some definitions of cost.

Runtime reflection on the other hand is useful but it also puts up obstacles not easy to overcome. For example it is one major reason we still have no decent ahead-of-time compilation in Java.

Re:Fun with C++26 reflection: Keyword Arguments by flohofwoe on Tuesday February 11, 2025 @02:59AM (#43010185)
I'm in the opposite camp, runtime reflection is useless, and almost always points to a design flaw while compile time reflection is actually useful (for obvious things like automatically building a serialization layer or an UI which represents the type, or building types from other types).

I'm sure that C++26 has implemented it in a way which is highly unpleasant to use though ;)

Re:Fun with C++26 reflection: Keyword Arguments by jcranmer on Tuesday February 11, 2025 @09:59AM (#43013486)
The element of runtime reflection that is the most useful is something along the lines of "here's function, here's a list of arguments, go call this function with those arguments".
Re:Fun with C++26 reflection: Keyword Arguments by xmcqdpt2 on Wednesday February 12, 2025 @07:04AM (#43024492)
Having to do this by reflection is a problem in principle solvable by types. Here is a function of type (A, B, C) => R, and here is a tuple of arguments of type (A, B, C), go call this function with those arguments.

Most programming languages make it hard to easily express those constraints so reflection is used instead.

Re:Fun with C++26 reflection: Keyword Arguments by nickelpro on Tuesday February 11, 2025 @03:40AM (#43010434)
Compile-time reflection is by far the most useful

It replaces the plethora of code generators that currently surround C++ like flies

Re:Fun with C++26 reflection: Keyword Arguments by pjmlp on Tuesday February 11, 2025 @03:00AM (#43010188)
We have add decent AOT compilation in Java almost since 2000, with Excelsior JET being one of the first vendors to offer it, but few are willing to pay for such tools.

Also I consider ART, GraalVM and OpenJ9 decent enough as free beer AOT.

Re:Fun with C++26 reflection: Keyword Arguments by badmintonbaseba on Tuesday February 11, 2025 @06:38AM (#43011666)
You can build runtime reflection on top of compile time reflection, it's impossible the other way around. Compile time reflection is a superset of what runtime reflection can do.