Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Reflection is not possible in Rust?


It is somewhat supported at the moment, but it's experimental and we may remove the support for it. Reflection always carries an overhead in terms of binary size and as a result many of us feel that it's inappropriate for a low-level systems language like Rust.


In theory, given the attribute, and macro system, it should be possible to implement this as a library in the language, correct? I think that is vastly preferred over a constant runtime always hanging around.


Runtime reflection is rarely a good idea—it’s just that most languages don’t support any forms of compile-time reflection. Rust does have those tools, and has the power to replace the vast majority of cases where runtime reflection is used with compile-time behaviour.


If you are unaware, the base-language of Rust lacks a runtime. This limits what can easily be done in terms of reflection, when compared to languages like C# and Java.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: