Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Anyone out there read these books - Compiling for the .Net Common Language Runtime by John Gough? or Build Your Own .Net Language and Compiler by Edward Nilges ?

I am starting to make my Christmas list and these two caught my attention, just would be curious if anyone out there would recommend them.

posted on Sunday, November 21, 2004 5:26 AM

Feedback

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

I have and have read parts of Gough's book. It's very good, and of course, very compiler focused.
11/21/2004 3:09 AM | Robert Hurlbut

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Being an old compiler hacker, I've bought both books. The first book is decent discussion of the design of the CLR (from the persepctive of designing a compiler that emits MSIL). It seems to strike a good balance between theory and practice. The second book I haven't gone through yet thoroughly...but seems to be mostly practice with little theory. I.e., it's highly pragmatic for those that don't want/need the theory and would rather have a recipe for an already cooked compiler (which is available with the book). In my opinion, any good compiler writer should have all three types of books on their shelves: strict theory (the type of book used in CS Compiler Writing 1 and 2 courses), balanced theory and practice, and practical recipe-style.

Having said that the second book falls into the last category, note that it has attracted a lot of emotional reviews, both on blogs and Amazon. It seems most readers either hate it or love it. Justin Rogers wrote an interesting review:

http://weblogs.asp.net/justin_rogers/archive/2004/11/05/253091.aspx

that degenerates into personal attacks...

Then there's someone that really likes the book:

http://msmvps.com/williamryan/archive/2004/09/15/13576.aspx

And lastly, there's a strange thread in a google group:

http://groups.google.com/groups?selm=f5dda427.0406060353.4c7e37ea%40posting.google.com

All in all, I think the book will probably be worth having, but certainly not for the purposes Justin Rogers figured it would suit him. (Methinks Justin had higher expectations, namely more theory than practice...or at least a balanced approach.)

Maybe there should be a law that all compiler/language books be forced to carry two thermometer scales on the back cover signifying content levels of theory and practice. And, of course, Amazon should be carrying this metadata on their website as well, to prevent disappointed readers from buying the wrong type of book. (The thermo-bars labelled "Beginning", "Intermediate", and "Advanced" don't make any sense for language/compiler books, as there's always been the argument over whether theory is a "beginning" or "advanced" skill-level and whether practice is a "beginning" or "advanced" skill-level... Some professors believe that teaching theory is a first quarter CS Compiler course and practice is the second quarter course. Then, there are others that believe in teaching practice first, then explaining it by teach the theory afterwards. Personally, I think the best CS courses are such that BOTH quarters have BOTH theory and practice. But I've never met a professor that agreed with me on that...)

Thus, it depends upon what your requirements are for said book. Neither are pure theory books. Of course, for theory you should have the classics:

Principles of Compiler Design, ISBN 0201000229
Compilers, ISBN 0201100886 <--- (aka "dragon book")

but only AFTER going through the following classics:

The Design and Analysis of Computer Algorithms, ISBN 0201000296
Data Structures and Algorithms, ISBN 0201000237

all strangely enough authored by Alfred Aho and Jeff Ullman.

Of course, if you really want a good Xmas present, get the 3-volume cased set of Knuth's Art of Compuer Science:

http://www.amazon.com/exec/obidos/tg/detail/-/0201485419/qid=1101053579/sr=1-1/ref=sr_1_1/103-6494477-5427845?v=glance&s=books








11/21/2004 3:17 AM | Steve Hall

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

I haven't finished John Gough's book but it is quite good. The other book I have flicked through in a bookstore, and I _THINK_ the parser for the language was written in VB6. Yikes. Check that out before buying it.
11/21/2004 10:37 PM | JosephCooney

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Hi, this is the author of Design Your Own .Net Language and Compiler.

First of all, the parser and compiler are NOT written in VB-6. They are written in VB.Net using Visual Studio 2003. They comprise 26000 lines of industrial-strength code...far more that what's delivered with many computer books.

The confusion may result from the fact that a subsidiary tool, a BNF analyzer, is written in VB-6.

What happened here was that I had to pawn my Vaio development system when it was time to write Chapter 4 on BNF. I'd run into a dearth of consulting assignments after Sep 11 and was kinda broke, but I had VB-6 Enterprise on my old Presario.

I agree with Steve Hall's main point, which seems to be that books address different needs. At two points in my book I urge the reader to "graduate" to The Dragon Book.

My book is meant to demystify the development of simple compilers for little languages and business rules and to get the hands-on crowd started on this type of development.

As to "theory" vs. "practice". I have long noticed a type of schizophrenia in the computer field, in which people self-select into areas labeled "theory" and "practice".

Then, safely esconced in their respective walled communities, they tend to hurl dead rats and offal at the other side.

The problem is that all of computer "science" is practice.

"Theory" and "practice", properly understood, are not labels for widely separable activities but names of what we do. When we design we formulate a theory, when we implement we engage in practice.

But the two areas are considered standalone, with the result that outside such luminaries as Edsger Dijkstra, the theorists produce useless theories and the praxis is flawed, not only by reinvention of the wheel per se but also by reinvention of the wrong wheel.

It is possible to write compilers in VB-6 although of course the compiler in my book is VB.Net. The problem is that their runtime is both undocumented and slow, but the really interesting question is whether the author knew what he was about.
11/22/2004 1:21 PM | Edward G. Nilges

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Thanks for the reviews guys and thanks to Edward Nilges for putting his reply in too (I don't get authors giving me their opinions too often ... or ever).

I think I'll ask for both books!
11/24/2004 11:11 AM | Jason Haley

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Jason:

I wrote the favorable post of Edward's book on my blog referenced above and wholeheartedly stand by it. I've given it out to three expereienced .NET Developers and everyone really liked it.

Edward is also very attentive regarding questions and he'll definitely help you out if you have any problems.

The stuff with VB6 though - I don't know why that freaks people out so bad. Like Edward said - it's a BNF parser but pretend it was written in VB6 for a second - writing a .NET Language in VB would still be an eye opener and would port right over.

I promise you that if nothing else - it will really get you thinking and offer some really interesting perspectives that will help you out at work. I never met Edward or even spoke to him before I wrote a review about his book - since then I've developer a tremendous amount of respect for the guy
11/29/2004 11:53 AM | Bill

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Jason:

I've been working my way through the Nilges book, and I'd heartily recommend it. It isn't a skimming book, though, as evidenced by those people who "skimmed it at the bookstore" and didn't like it. When I first looked it over, I wasn't too impressed, either. It is definitely a reference book for the code that accompanies it. Prepare to spend a lot of time in Visual Studio looking over his code.

Yeah, there is some VB6 and the rest of the code is in VB.Net, but that isn't really a big deal. I kind of think that it emphasizes Edward's point that, in .Net, the choice of language should be a "lifestyle choice." Personally, I love the fact

The only negative that I can find about having VB6 in it is that I don't have Visual Studio 6 anymore, so I can't compile up the code. :)
12/1/2004 4:05 AM | Corey

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

I'm with you Corey
12/7/2004 2:03 PM | Bill

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

I've been working on porting the quickbasic compiler (and Integer Calculator) to C# and am keeping fairly extensive notes. I just finished a long post (11-12 pages) on my port of the QuickBasic lexical analyzer from chapter 5. http://www.coreyhaines.com/coreysramblings/PermaLink.aspx?guid=b8a9e95c-2cba-4a6e-b9a0-1968a784e0b1

There's also a couple posts on my port of the Integer Calculator on my site, as well.
12/12/2004 4:58 AM | Corey Haines

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

Mr. Nilges,

Any plans to port the source over the C#? I know of some VB.Net to C# converters that do most of work. I want your book, but don't prefer VB.net.

Regards, Stu
5/24/2005 9:39 AM | Stuart

# re: Compiling for the .Net Common Language Runtime and Build Your Own .Net Language and Compiler?

I am working on a C# port
9/30/2005 5:42 AM | Edward G. Nilges

Post Comment

Title  
Name  
Url
Comment   
Please enter the following code into the box below to stop spammers

  
Enter Code Here *