3 ms·
.Net relies on runtime code generation for generics. This allows .Net to support generic instantiation with a type parameter the compiler hasn't seen at compile
by magicalhippo 8y ago
.Net relies on runtime code generation for generics. This allows .Net to support generic instantiation with a type parameter the compiler hasn't seen at compile-time. Thus I don't need the source code for your generic data structure to use it with my custom types. I can just link in the compiled library.
It also allows the .Net regular expression library to be able to dynamically generate IL-code to match a given regular expression, which is then dynamically loaded into the process and JIT compiled to machine code. Other projects surely use the same facilities to dynamically generate and run specialized code based on user input and/or environment.
- pjmlp 8y agoNot when doing AOT compilation.
- magicalhippo 8y agoIndeed. The question was why do JIT instead of AOT, and I tried to list some benefits.
- pjmlp 8y agoAh ok, sorry for the pedantic comment then.
- magicalhippo 8y agoNo worries! I realize I could have been more explicit in my original comment.