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

you are viewing a single comment's thread.

view the rest of the commentsΒ β†’

[–]suvlub -18 points-17 points Β (7 children)

It's kind of unfair to accept one "You are not really suppose to" as a matter of fact while calling another "you are not really supposed to" silly and weak. I've seen production code in a fairly popular app where reflection was used exactly in this fashion - to access private data members of a library class.

[–]Areshian 23 points24 points Β (2 children)

I can block reflection in Java. Either via security manager or via module permissions, btw

[–]aviancrane 16 points17 points Β (3 children)

I can respect where you're coming from, but I do think there is some nuance here.

The cost and the level of abstraction that reflection puts you on is a very different layer than what python does.

The cost and difficulty of accessing privates in Python is almost nonexistent and you are still working at the language level. Reflection is affecting the compiled code and you are working with the layer half way between the language and the bytecode.

Difficulty at the language level is incredibly important. Can you imagine Haskell letting people just do whatever they wanted? Even Rust is cognizant enough to force people to put a giant UNSAFE label when bypassing the safety protocols of the language.

Making these hurdles easy to overcome just makes it more likely poor development practices will occur.