Which dragon book is better?

I'm now looking at compiler design (in order to write a decompiler) so ... can you help me decide which dragon book is better -> the red or the green?  I am assuming if you know what I am talking about, you'll know the better of the two ...

posted on Sunday, September 25, 2005 2:52 PM

Feedback

# re: Which dragon book is better?

Jason,

I own The Red Dragon book. I'm old, but not old enough for The Green Dragon book in it's original form (I was in eighth grade when it was first published), so I can't give an opinion on which is better.

---O

p.s. How was code camp? Was your talk well received?
9/25/2005 8:03 PM | optionsScalper

# re: Which dragon book is better?

One other thing . . .

It might be useful to find out what is on the shelves of the members of the CLR team or the "Programming Principles and Tools" team at Microsoft Research. What do they read? What did they find useful in their courses?

I'll bet that a few of them would have an opinion.

http://research.microsoft.com/research/ppt/

---O
9/25/2005 8:07 PM | optionsScalper

# re: Which dragon book is better?

---O: Good idea, I'll try and contact some of those guys. I'll write an entry about the code camp presentation later this week - short story is it went a lot better than I expected!
9/26/2005 5:31 AM | Jason Haley

# re: Which dragon book is better?

Hi Jason - I was in your IL session & we met afterwards at the Westin

Anyway

Forget the dragon books - they're both a little long in the tooth at this time (esp green) and they're really focused on the basic theory behind language implementation - problem is, couple of smart people have really changed that world.

First, the person you want to follow is Terrance Parr, now teaching in SF. He's the guy who did the Purdue compiler construction tool set (PCCTS) and changed _all_ the rules. The short of it in geek terms is his PhD is based on how languages can be defined with infinite lookahead, i.e. the LALR(1) restriction and other forms are gone. Look around on google for 'ANTLR' which is the implementation of his work.

He's got a book out on it, which you'll definitely want if you use ANTLR - it's the most powerful parser generator I've ever used, and I'd never go back to any of the 'exlax' (lex + yacc) variants after I learned it.

There's nothing wrong with the red book per se, it's just that it's the fountainhead, and the world has moved on

other books to consider are;

An Algebraic Approach to Compiler Design - this is pure hairball theory stuff, sort of the green book on steroids in greek

There was another book on compiler design in C++, can't find it on Amazon, but I used it in the mid/late 90s and it was pretty good

You also probably want two books to deal with the two sides of the coin

Front end book - lexical scanning and parsing - building the tree that represents the source program - this is terr's book, or the red book, or the others i mentioned

Back end book - code generation, term rewriting, optimization, register spilling - some google buzz words - this is the process of walking the tree produced by the parser, and thrashing around to generate the compiled output - it makes writing a parser look like a walk in the park - this was a closely held black art when I was writing compilers, you'll probably need to research this

Also, remember decompilation is a beast of a problem, far far worse than disassembly (tho not so bad in .net to be sure) - the problem is that there is a 1:N expansion from the parse tree to legitimate and efficient realizations of the tree in machine code

I'd strongly recommend an ACM portal account - you're probably going to need to read some stuff that hasn't made it into books yet.
9/26/2005 12:16 PM | Mark Mullin

# re: Which dragon book is better?

Hello, we met at the code camp.

I owe you pointers to decompiler research paper,
if you remember.

Please google "Cristina Cifuentes" to get in her homepage.
One paper is the most related to your current project:
"Assembly to High-Level Language Translation" which is published
in 1998.

If you'd like to choose between red and blue dragon book,
I suggest red one.

I'm not quire in favor of Mark's recommendation on the
compiler reading, although I need to read it more in depth.

regards,

Hongjun
9/27/2005 11:28 AM | Hongjun

# re: Which dragon book is better?

Mark and Hongyun: It was great talking to you both at code camp. Thank you for all the information!
9/27/2005 5:42 PM | Jason Haley

# re: Which dragon book is better?

sheesh.. I am so old that I have forgotten the color of that book I had back in school..
;-)
9/28/2005 11:09 AM | SBC

# re: Which dragon book is better?

Check out the new one on Nov 15th: 21st Century Compilers http://www.amazon.com/exec/obidos/tg/detail/-/0321131436/ref=ase_blogtkachenko-20/103-5748891-3845459?v=glance&s=books
10/3/2005 5:06 PM | Ernie Booth

# re: Which dragon book is better?

Ernie: nice find! I didn't know that was coming out... so I ordered the red dragon book yesterday.
10/4/2005 4:39 AM | Jason Haley

Post Comment

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

  
Enter Code Here *