News for hackers. Stuff that matters.
Re:Cost of enum-to-string: C++26 reflection vs. the old ways by cogman10 on Wednesday May 13, 2026 @10:02AM (#48122035)
It comes up pretty frequently in java. Serialization/Deserialization, adding capabilities based on type, Adding new capabilities to a type, general tuning (for example, adding a timing or logging call onto methods).

Almost all the Java web frameworks are giant balls of reflection. Name a function the right way or add the right magic annotation and the framework will autowire it correctly.

It's a pretty powerful tool. (IDK if C++'s reflection is as capable, but this is what was enabled by java's reflection).

Re:Cost of enum-to-string: C++26 reflection vs. the old ways by SuperV1234 on Wednesday May 13, 2026 @10:48AM (#48122680)
Java reflection is another beast altogether as it is runtime reflection. C++26 reflection is purely compile-time, which not only means it adds zero runtime cost, but also prevents those kind-of-insane use cases you see in Java and C#.
Re:Cost of enum-to-string: C++26 reflection vs. the old ways by pjmlp on Thursday May 14, 2026 @02:23AM (#48131793)
I think C++ devs have to eventually update their knowledge how Java and .NET work when talking about reflection.

Yes, originally they only supported runtime reflection.

Nowadays they have compile time tooling as well, via plugins, annotation processors, and code generators.

Which is exactly how you can have a Spring like frameworks that do all the AOP magic at compile time, for native code with GraalVM or OpenJ9, like Quarkus or Micronaut.

Re:Cost of enum-to-string: C++26 reflection vs. the old ways by david422 on Wednesday May 13, 2026 @10:11AM (#48122159)
> Almost all the Java web frameworks are giant balls of reflection. Name a function the right way or add the right magic annotation and the framework will autowire it correctly.

I find this to be very powerful, and also very unintuitive/undiscoverable at the same time.

Re:Cost of enum-to-string: C++26 reflection vs. the old ways by cogman10 on Wednesday May 13, 2026 @10:43AM (#48122612)
Initially, but it very quickly becomes discoverable once you are familiar with how things are working.

Most frameworks in Java are very similar. The ones that aren't are effectively doing what "expressjs" does in terms of setup, which is still pretty discoverable.

Most java frameworks rely on annotations rather than naming schemes which makes everything a lot easier to grok.

Re:Cost of enum-to-string: C++26 reflection vs. the old ways by kuboble on Wednesday May 13, 2026 @10:42AM (#48122600)
Reflection is simply a syntax vinegar for duck typing.