Source

Alt text:

A screenshot from the linked article titled “Reflection in C++26”, showing reflection as one of the bullet points listed in the “Core Language” section

  • Zangoose@lemmy.worldOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 months ago

    See my other comment for more detials but it kind of destroys the type safety of the language. In Java for example, it lets you modify private/protected fields and call private/protected methods.

    It’s also slower than accessing a field normally since you need to do a string lookup (but slightly faster than a hashmap/dictionary) so if you use it over a large enough list it’ll cause slowdowns.

    Most use cases for it in Java/C# revolve around testing, serialization, and dynamic filtering/sorting. And most of those cases can be handled more safely using macros/attributes (EDIT: and templates as well, though those are also pretty painful to deal with) because that gets handled at compile-time in C/C++.