3 ms·
> Why do you think that reflection is a bad idea? OK, reflection isn't necessarily a bad idea. Clearly development tools need it, including future tools that r
by mwcampbell 10y ago
> Why do you think that reflection is a bad idea?
OK, reflection isn't necessarily a bad idea. Clearly development tools need it, including future tools that run in the browser (e.g. an in-browser IDE). But I think that applications that are not development tools should not use reflection, because it interferes with static optimization, as the article that I linked in my original comment explains. So most libraries should probably not use reflection either. That means we need an alternative to reflection. For example, chapter 10 of _Kotlin in Action_ uses reflection to implement a serialization library. I think it would be better to use build-time code generation for that, even outside the JS use case (e.g. reflection interfers with optimization of Android app packages with ProGuard).
Edit: By the way, thanks for taking the time to respond.