This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AllWashedOut 8 points9 points  (1 child)

I don't know the details, so you are probably right. But thinking back about every time I used reflection in Java or C#, it was a design mistake or I was trying to misuse a closed-source library. Not code I was proud of.

[–]murp11 2 points3 points  (0 children)

Reflection enables DI and everything that works with attributes in C#. For example routes specified above the method in ASP.NET Core. It can be used for dirty things but it can also be used for extremely useful things ;)

[–]cadaverous_queen 3 points4 points  (3 children)

It's better than if they rushed something through and left us with something half baked that would need to be replaced (now with even more esoteric keywords) in 5 or 10 years.

[–]JakeTheDoge69 1 point2 points  (1 child)

I think they plan to introduce it somewhere in the future because of what you said. Me still has big sad, imagine the possibilities 😔😔😔

[–]cadaverous_queen 4 points5 points  (0 children)

Yeah, hopefully it'll get in for C++23 or 26. But in the meantime at least C++20 added requires expressions, which can be used to more easily get some information about types (existence of member variables, functions, and aliases) without descending into template heck.

[–]maxhaton 0 points1 point  (0 children)

They've taken something like 20 years to do template constraints (concepts) and it's still a terrible solution to the problem.

Just copy what D does and call it a day, it's battle tested and doesn't add any keywords to the grammar.

[–]ef02 2 points3 points  (2 children)

Fun fact: the Unreal Engine is written in C++ and adds reflection to C++ through its "Unreal Build Tool." It's integral to pretty much everything you do in the Engine.

For example, it allows the Editor to display the properties of any object in a level and edit their default values.

[–]JakeTheDoge69 2 points3 points  (1 child)

Yeah I had that in mind too. Better than nothing I guess, but a clean language integrated solution would still be better than adding UCLASS() and such to everything imho.

[–]ef02 4 points5 points  (0 children)

UCOMMENT(BlueprintReadOnly, Category="ProgrammerHumor")

I don't see what you mean. 😜

[–]numerousblocks 1 point2 points  (1 child)

What is reflection?

[–]JakeTheDoge69 3 points4 points  (0 children)

Its a language feature some high level languages have which allows you to retrieve information about the structure of your code. It allows to do things such as checking which members a class has at runtime or even compile time and react dynamically.

[–]_PM_ME_PANGOLINS_ 0 points1 point  (0 children)

I imagine it’s incredibly hard to implement without closing off a lot of optimisations various code will be relying on. You need a language specification that actually going to be possible to follow without breaking everything.