Follow

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 Well, it's natural in the sense that it feels like something our own minds would do. But unnatural in that it feels like something computers don't do. Right?

@tulpa more or less. Yeah. The lower level you think about computers, the more it feels like something that shouldn't be happening. In some way it makes the program feel that little bit less "real" for the lack of finding a better term for it.

@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.

@talon

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.

@talon

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! Admins: @Talon and @Mayana.

<svg xmlns="http://www.w3.org/2000/svg" id="hometownlogo" x="0px" y="0px" viewBox="25 40 50 20" width="100%" height="100%"><g><path d="M55.9,53.9H35.3c-0.7,0-1.3,0.6-1.3,1.3s0.6,1.3,1.3,1.3h20.6c0.7,0,1.3-0.6,1.3-1.3S56.6,53.9,55.9,53.9z"/><path d="M55.9,58.2H35.3c-0.7,0-1.3,0.6-1.3,1.3s0.6,1.3,1.3,1.3h20.6c0.7,0,1.3-0.6,1.3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z"/></g></svg>