Friday, 25 February 2011

CIL Programming: Under the Hood of .NET



CIL Programming: Under the Hood of .NET
| 2002-06-16 00:00:00 | | 0 | .NET


The Common Intermediate Language (CIL) is the core language of .NET. Although .NET developers often use a high-level language (such as C# or VB .NET) to develop their systems, they can use CIL to do anything allowed by.NET specifications&emdash;which is not the case for C# and VB .NET. Understanding how CIL works will provide you with a deep, language-independent insight into the core parts of .NET. This knowledge is essential for creating dynamic types, a powerful part of the .NET Framework.

In CIL Programming: Under the Hood of .NET, Jason Bock offers an in-depth tutorial on programming in CIL. First, Bock discusses the basics of .NET assemblies and manifests. He then shows how to create assemblies in .NET&emdash;including the ilasm directives and CIL opcodes, and how these are used to define assemblies, classes, field, methods, and method definitions. Bock also covers the ways in which C#, VB .NET, and other non-Microsoft languages emit CIL, and how they differ. Finally, he reveals how developers can create dynamic assemblies at runtime via the Emitter classes.

After reading this guide, you will gain a better understanding of CIL and how to program directly into it. CIL Programming: Under the Hood of .NET is a must-have on every .NET developer's desk!



User review
Great for learning Reflection.Emit
My goal in reading this book was not to learn how to write IL in notepad and compile it via ilasm.exe. I wanted to learn the basics of IL and learn how to use the Refelction.Emit namespace to create dynamic types at runtime. This book does a great job at teaching this. I think the two chapters about Reflection.Emit are the best in the book.

User review
CIL - Microsoft's Assembly for .NET
Has this ever happened to you,,. There's this new technology or programming language that you're dying to learn, but there are no books. Finally, someone writes a book, you get the book from the bookseller (Amazon), you open the book, and you thumb through the pages. Well, that's the way I felt about learning Microsoft IL for .NET. I really was keen about learning .NET's `assembly language` because throughout my career I found that having low level knowledge about how a system is put together is very, very useful. Now, I'm not suggesting that you stop everything you're doing and run out to learn CIL programming. However, I believe that if you want to be a serious .NET professional, learning CIL should definitely be on your To-Do list.

So what about Bock's Book: `CIL Programming: Under the Hood of .NET`? In a word - disappointing. Bock spends most of the book's first chapter entitled `Language Interoperability` on detailed discussion of programs written in a variety of languages. He's trying to make the point that the CLR allows programs written in different languages to freely interoperate. Duh? Why spend the better part of the book's opening talking about everything but CIL. There's even an Oberon (?) programming sample here.
The second and third chapters on ILASM Directives, and, CIL Opcodes, respectively, read like my weekend shopping lists. While it is true that programming books have to regurgitate all the nasty details of the programming language, the good books tell its readers how to internalize the information and describe useful ways of summarizing the information in one's mind. That is, the authors of the better books have figured out some rhyme and reason to the language and they share these insights with their readers. On the other hand, this is what I found in these two most important chapters of Bock's book: the more I read, the more questions I had. I wound up spending significant time on the NET trying to resolve questions that were raised in the material in these two chapters. Clearly, the author did not anticipate these questions.
The fourth chapter, `ILASM and CIL in Practice` is a decent discussion of a typical sample program in IL. It demonstrates some of the IL constructs and programming concerns discussed in the previous chapters.
Chapter 6 is interesting. Here the author talks about and contrasts the IL generated by various programming languages. Some of the VB.NET and C# exposés were eye-opening, but then Bock goes back to Oberon again.
The author ends off the book in chapters 7 and 8 with some very long and tedious samples. I got nothing from this. Chapter 9, the last in the book, is a two-pager on `CIL Tips`.

So why do I give this book 3 stars?
1) The book includes Chapter 5, a well-written and interesting discussion about CIL Debugging.
2) Right now, Bock's book is one of three books that talk about CIL. It is the only book that is targeted directly at programming. Although John Gough's `Compiling for the .NET Common Language Runtime` is an excellent book, it is very specialized and targets would-be compiler authors. I didn't read the third book in the IL arena, Serge Lidin's `Inside Microsoft .NET IL Assembler`, but I did thumb through it several times (you know what little that is worth): this book strikes me as being very difficult.

RECOMMENDATIONS:
If you need to learn IL Programming right now, buy Bock's book - read the second half of chapter 1, and read Chapters 2-5, maybe Chapter 6. If you have the time, money, and inclination, then buy and read Gough's book. You'll need a lot of time for Gough, but you will definitely learn.

If learning IL is not that pressing right now, I would wait to see if someone else releases a better book.

User review
CIL - Microsoft's Assembly for .NET
Has this ever happened to you,,. There's this new technology or programming language that you're dying to learn, but there are no books. Finally, someone writes a book, you get the book from the bookseller (Amazon), you open the book, and you thumb through the pages. Well, that's the way I felt about learning Microsoft IL for .NET. I really was keen about learning .NET's `assembly language` because throughout my career I found that having low level knowledge about how a system is put together is very, very useful. Now, I'm not suggesting that you stop everything you're doing and run out to learn CIL programming. However, I believe that if you want to be a serious .NET professional, learning CIL should definitely be on your To-Do list.

So what about Bock's Book: `CIL Programming: Under the Hood of .NET`? In a word - disappointing. Bock spends most of the book's first chapter entitled `Language Interoperability` on detailed discussion of programs written in a variety of languages. He's trying to make the point that the CLR allows programs written in different languages to freely interoperate. Duh? Why spend the better part of the book's opening talking about everything but CIL. There's even an Oberon (?) programming sample here.
The second and third chapters on ILASM Directives, and, CIL Opcodes, respectively, read like my weekend shopping lists. While it is true that programming books have to regurgitate all the nasty details of the programming language, the good books tell its readers how to internalize the information and describe useful ways of summarizing the information in one's mind. That is, the authors of the better books have figured out some rhyme and reason to the language and they share these insights with their readers. On the other hand, this is what I found in these two most important chapters of Bock's book: the more I read, the more questions I had. I wound up spending significant time on the NET trying to resolve questions that were raised in the material in these two chapters. Clearly, the author did not anticipate these questions.
The fourth chapter, `ILASM and CIL in Practice` is a decent discussion of a typical sample program in IL. It demonstrates some of the IL constructs and programming concerns discussed in the previous chapters. Chapter 6 is interesting. Here the author talks about and contrasts the IL generated by various rogramming languages. Some of the VB.NET and C# exposés were eye-opening, but then Bock goes back to Oberon again. The author ends off the book in chapters 7 and 8 with some very long and tedious samples. I got nothing from this. Chapter 9, the last in the book, is a two-pager on `CIL Tips`.

So why do I give this book 3 stars?
1) The book includes Chapter 5, a well-written and interesting discussion about CIL Debugging.
2) Right now, Bock's book is one of three books that talks about CIL. It is the only book that is targeted directly at programming. Although John Gough's `Compiling for the .NET Common Language Runtime` is an excellent book, it is very specialized and targets (would-be) compiler authors. I didn't read the third book in the IL arena, Serge Lidin's `Inside Microsoft .NET IL Assembler`, but I did thumb through it several times (you know what little that is worth): this book strikes me as being very difficult.

RECOMMENDATIONS:
If you need to learn IL Programming right now, buy Bock's book - read the second half of chapter 1, and read Chapters 2-5, maybe Chapter 6. If you have the time, money, and inclination, then buy and read Gough's book. You'll need a lot of time for Gough, but you will definitely learn.

If learning IL is not that pressing right now, I would wait to see if someone else releases a better book.


Download this book!

Free Ebooks Download

No comments:

Post a Comment