Is there any scenario where programmer use IL as their primary language for writing code
Most of the developer use one of the core .NET language ( Like c#, vb.net, c++/cli etc) to create their applications/developers. I was just wondering if any one would开发者_如何学编程 use Intermediate Language (IL) as their primary language for their day to day job as programmer.
I can't imagine a situation where you would need to. Assuming the .NET compilers are decent, it would be wise (and more efficient in terms of time spent coding) to leave IL-level optimizations to the compiler, rather than trusting yourself to do them.
In the time required to write some code in IL, you could do 10x the work in C# in the same time, and the .NET compiler would likely do a better job than we would of optimizing it too.
No, there is no reason for programming in IL unless you are forced to.
IL is not invented as a programming language. It is (as the name implies) an Intermediate Language -- one that is generated as output from a high-level language and then later compiled into machine code, typically in runtime by a JIT-compiler.
Although I agree with the other answers, I would like to add that there are a few cases where it can be useful to write IL:
- dynamic code generation (using
Reflection.Emit
), although it's typically done for a very short piece of IL code - If you need to do something that is supported by the CLR but not by your usual langage
精彩评论