I can't really put a finger on why, but for some reason runtime reflection in programming languages makes me feel slightly uneasy in the back of my mind. It feels like it's both cheating, but it should also be perfectly natural somehow. But it's neither. But at the same time it's also both.
Compile time reflection? Perfectly fine. Makes total sense.
Runtime reflection? Weirds me out every time I use it or see it used. Just that tiny little bit.

@talon in java this felt quite natural, maybe because it was all so high level and abstract already. I think I only ever used reflection to do naughty things like call private methods though...

@piggo Or deserializing JSON into structs or classes with a single line of code.
I mean... using lots of macros and templates and code generation you can probably do similar things in languages that directly compile to binary and not just some intermediate bytecode like Java or C# or whatever, but no matter what, it just always feels "wrong" to me somehow.


wanted to write a little rant on how reflection and laziness are very closely linked, but technically dlopen and dlsym together are also a kind of reflection. so, not quite so convinced of my own argument any more :dragnmlem:

@dhivael Even in languages that have good reflection support I refuse to use it unless I absolutely have to, because I agree. It ends up in a big mess more often than it helps, and the time you spend figuring out why your random reflection breaks is better spent just avoiding it in the first place I feel.


yeah, same. using reflection is tantamount to writing in an untyped fragment, which is ... not great

@dhivael Nevermind that once you start using runtime reflection, your compiler can't help you once you mess up. Things that become convenient compile time errors now crash your program. Woo!

Sign in to participate in the conversation

A fun, happy little Mastodon/Hometown instance. Join us by the fire and have awesome discussions about things, stuff and everything in between! Please read our rules before doing that, though; applications without the password that confirms you have done so will be rejected. Admins: Talon and Mayana.