Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I was reading through the code of StackOverflow's new SQL Object Mapper. And I noticed at the bottom of the SqlMapper.cs there is some code that I had never seen before. After reading some of the documentation on MSDN and a tutorial on MSIL this feels a little over my head.

As a professional .NET developer (6 years), should I invest time to learn this? What is the advantage of understanding the ILGenerator?

I hope I'm not confusing things and the question is clear.

Thanks!

share|improve this question

3 Answers 3

up vote 5 down vote accepted

I can't write MSIL, so keep in mind that my answer would be akin to the blind leading the blind :)

That said, I think it may be a better question to ask "Why would you want to work directly with MSIL"? The answers would then help you decide if you even need to worry about it.

This question does a pretty good job at going over what you can do in MSIL that you can't do in other .net languages - which is presumably the main reason you'd even worry about MSIL. If things listed here are foreign to you, then read up on those topics first. I'd also recommend reading CLR via C# by Jeffrey Richter if you haven't already. It is definitely something you should read (or be familiar with the concepts covered) before you worry about MSIL (it does go into MSIL, and the things that the CLR - and hence MSIL will allow you to do that C# doesn't).

Bottom line, I'd say that there are plenty of prerequisites to learning to work directly with MSIL, and by the time you've mastered those concepts you'll know when you should break out the MSIL and learn/use it.

share|improve this answer

I'm currently working with something called Object List View. Some of the magic behind how it works is that it generates IL code on the fly. I've never encountered this before, and I've been working with .NET for about as long as you have.

I can't tell you what you should or should not be studying on your own, but this is something I am planning on learning to do on my own this summer.

share|improve this answer
    
thanks for the information, it does look like an interesting control. –  Peter May 26 '11 at 8:07

Yes, you'd better learn MSIL, because code generation is a very powerful (probably, the most powerful) programming technique, and in .NET it is really easy to compile a highly efficient code from your domain specific languages. Some of the IL features are not available from C# (e.g., tail calls).

Needless to mention that it will also help to understand better how .NET works. And it won't require a significant effort to learn, as .NET is one of the simplest VMs out there, it is much simpler than, say, JVM.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.