Hacker News new | ask | show | jobs
by wallstop 8 days ago
I mean, yes, but also, no - you can generate and cache (or return manual ownership to the caller) IL/whatever runtime code that doesn't box for any reflection thing that you need on the fly, assuming the type information is available. Like you make it an explicit API to do the code gen, no JIT required.

Just because the code isn't baked into the binary doesn't mean that it theoretically can't be done at runtime. At least, AFAICT.

1 comments

It seems like you are contradicting yourself here. Just generate code that doesn't box on the fly, but without a JIT compiler? Boxing isn't even the biggest issue here - you could probably avoid that with a strongly typed reflection API, but I don't know if that makes it less useful.

IMO the big issue is AOT compilers only compile code that is referenced statically. Without a JIT you would have no choice but to error if you try to call something that wasn't compiled in. Compiling everything is not an option because generics.

JIT != capability to dynamically generate and run code at runtime, was my only point. A JIT can and does do that, but it is not the only way of doing that. And if there's a homegrown project like this, they can do whatever they want. Such as explicitly provide an API to do reflection like things instead of requiring JIT to implicitly handle it on the fly.

An approach that doesn't need runtime would be to allow reflection for types provided at compile time (say, with a config file). There are many ways to approach reflection, from none to some to full. This appears to have chosen none. It could have chosen some, or potentially even full.

Makes more sense doing what .NET is currently doing for NativeAOT right now: use source generators to extract what you need at build time.