Book Review: the CLR via C#
As promised, here’s my review of the January book, the CLR via C# by Jeffrey Richter, from my 2010 tech book reading list.
Rating -
![]()
(3 out of 5 stars)
Prerequisites
- IL Tutorial – Although most of the samples in the book are in C#, there are several key code samples in IL and the book doesn’t provide much help for the uninitiated. I think I got a few hundred pages into the book before I relented and took a 100 page reading detour through the first couple of chapters of Advanced .NET Programming so that I could get a better grasp of the basic IL instructions and concepts. My reading sessions went much more smoothly after I did that.
The Good
- Illustrative scenarios with diagrams – I’ve read about value and reference types, the stack and the heap, boxing and unboxing, and the generational algorithm for garbage collection several times before, but I felt like this was the first time that I moved beyond a superficial conceptual
understanding. This is primarily due to Jeffrey Richter’s approach of providing concrete code-based examples interspersed with helpful state diagrams. The picture to the right from his “How Things Relate at Runtime Section” in Chapter 4 shows the contents of the thread stack and heap as of a certain line in a simple code sample. His diagrams showing the contents of the heap, the finalization list, and the freachable queue as of each line in the sample code from his chapter on automatic memory management were also incredibly helpful in understanding how garbage collection works. - Critical Analysis – The author periodically presents some strong and sometimes unexpected opinions on various topics through the book. Despite disagreeing with him on several points, such as sealing classes by default or avoiding the use of properties, I always felt like I gained new insights from reading his arguments. For example, I never knew that switching from unsealed to sealed breaks backward compatibility or that the JIT compiler produces more efficient code for sealed classes because it can call it non-virtually. Neither argument was enough to outweigh the testability issue in my mind, but it did give me a better mental hook to assimilate the knowledge than just reading a bunch of random facts in the style of a reference book would have.
- Novel Perspective – A few years ago I probably would have dismissed the book based on the title and the frequent use of IL as code samples because my focus as a developer was much more on the language than the runtime. Much like with the hardware on my computer, I expected the virtual machine my code was running on to just work for me and preferred to be shielded from what was under the hood whenever possible. However, as new language features rely more and more on the compiler to perform the magic, the potential for gaining insight into the language by moving closer to the runtime and looking at the IL (Intermediate Language) that the compiler generates increases dramatically. For example, rather than having separate chapters on anonymous methods, lambdas, and closures like most C# books, this book simply has sub-sections in the delegate chapter entitled syntactic shortcut # 1, 2,3, and 4. The decision to use that structure alone did more to provide insight into these new features than the vast majority of other C# books that I have read.
The Bad
- Lack of editorial discipline – I have to admit that I experienced periodic bouts of boredom with this book because there were sections that read like reference manuals (e.g. tables with API descriptions) or else included excruciating details about edge cases that seemed to be included more for thoroughness than as a way to explore or illustrate an important concept. This was particularly frustrating because I found myself jumping into skim mode or not fully paying attention and thus almost missing the scattered gems. In my opinion, the book could have gone from good to great if an editor had told him to put a disclaimer about not being comprehensive in the Forward and then challenged him to trim at least a 100-150 pages from the book. In order for a book to be great, it has to hold my attention for the majority of the time and this simply didn’t do it.
- Outdated coding conventions (nitpicker’s corner) – It was pretty easy to ignore this, but I have to admit that it threw me for a loop to see all the m_ variable prefixes in the code samples. I thought it was especially odd since the book was published from Microsoft Press since Microsoft has officially discouraged Hungarian notation for quite a while.
What’s Missing?
- A larger perspective on virtual machines – I would have loved to have read a chapter that explained where the CLR fits into the larger picture of virtual machines. It would have been nice to know a little bit of history as well as some analysis of what is innovative about Microsoft’s runtime and what is lacking in comparison to other execution engines such as the JVM.
Recommended Sections & Chapters (for lunchtime perusal at the bookstore)
- How the Runtime Resolves Type References (Chpt. 3 – pg. 85)
- How Things Relate at Runtime (Chpt. 4 – pg. 107)
- Reference and Value Types (Chpt. 5 – pg. 123)
- Boxing and Unboxing Value Types (Chpt. 5 – pg. 129)
- Exceptions (Chpt. 20)
- Automatic Memory Management (Chpt. 19)
- Threading (Chpt. 23 & 24)
Conclusion – It definitely qualifies as one of the seminal .NET technical books that you should probably try to read it if you’re serious about increasing your depth of knowledge about C# and the CLR. However, if you do find yourself starting to lose interest while reading, then I recommend give simply yourself permission to skim sections that you are already familiar with. There are too many hidden gems in there to let the slow sections derail you from reading it cover to cover.
Popularity: 1% [?]
Comments(2)


[...] Link: Book Review: the CLR via C# | Caffeinated Coder [...]
[...] Book Review: the CLR via C# | Caffeinated Coder [...]