3 ms·
Reflection in C# is a thing, it isn't in either Go or Rust. I've read some kind of compiler shenanigans can get something that resembles reflection in C++. I l
by lillecarl 4y ago
Reflection in C# is a thing, it isn't in either Go or Rust. I've read some kind of compiler shenanigans can get something that resembles reflection in C++.
I love reflection, the fact that libraries can look at your types is really really cool.
Not saying it can't be done with a compiled language but I don't see it anywhere.
Being able to load a shared library, search it for classes implementing interfaces, instantiate them and call their methods is pretty slick too.
- pjmlp 4y agoGo has reflection, and you can make use of compile time reflection on Rust via the macros infrastructure.
- lillecarl 4y agoDoes that cover all mentioned usecases though? They're discussing source generation in this thread, not even close to the same thing (for certain usecases)
- pjmlp 4y agoKind of, you can use the parsing package for that, alongside the //go:generate infrastructure. Or you can use Go reflection package and generate the source code from it. Of if wanting to do something like Assembly.Emit, generate the machine code directly with a little help from unsafe and syscall packages. Depends pretty much on the actual use case.