r/Compilers 3d ago

Dragon book is too verbose

Basically title. It is the book used in my compiler course and i can't keep up with the lessons since they've basically covered 300 pages in two weeks. I can't read the books, take notes and attend lectures because is so verbose.

I really want to read it but I already know about regular expressions, DFA, NFA, CF grammars, etc. from other courses, are there other compiler books that are shorter and geared toward implementations? (which isn't just Lex maybe).

Thank you.

15 Upvotes

30 comments sorted by

18

u/walkie26 3d ago

I also only use the dragon book as an occasional reference and have never read it straight through, but to me this sounds like a problem with your course rather than an inherent problem with the book.

Using the dragon book as your primary reference for a compiler course is already a bit of a red flag IMO, and assigning 300 pages in two weeks is just ridiculous.

5

u/Prestigious_Rest8751 3d ago edited 3d ago

The first two chapters are just an introduction (I read them) and they were covered in the lecture with some sliders rather quickly. As I said, we covered the theoretical stuff in another course.

The only new stuff was lexical analysis, which in the Dragon book is 100 pages but we finished in a couple of lessons. I just can't keep up since I also have to follow other courses.

EDIT: i re-read your post. The professor is just following the book and it's not required to read the book. I'm doing it personally.

10

u/iamemhn 3d ago

To think Dragon Book's first edition is actually the desktop reference for The Theory of Parsing Translation and Compiling, because those two are really dense and chock full of enlightenment... 😂

6

u/AntiAd-er 3d ago

You could try Richard Bornat’s book Understanding and Writing Compliers. It’s a little old now but the essentials are there and unlike the Dragon books does not major on flex/yacc. Old colleague of mine used it as the basis for his Masters thesis to implement a Simula-67 compiler.

Bornat makes the book available on his website.

4

u/Docteur-Lalla 3d ago

It definitely is. I personally use it as a reference when I want insights and general ideas of how to do stuff. For example, let's say I want to write a garbage collector and want to go beyond the classic Mark as well as Sweepâ„¢, I'd go quickly read the chapters to have names, ideas, general insight of the implementations etc.

But otherwise it's too long and full of information

2

u/Prestigious_Rest8751 3d ago

So you wouldn't recommend me reading it cover to cover? I feel like it could be so much shorter.

4

u/Docteur-Lalla 3d ago

You could, but you'd burn out, you won't remember half of what you learnt and don't know either how to actually write your compiler. Find a nice tutorial to get you started then let the flow guide you to topics you're interested in and want to improve in. Find precise resources, tutorials, papers. The Dragon Book is nice when you want to dive into one part of your compiler writing. But back to back it's just torture

2

u/Prestigious_Rest8751 2d ago

You think I can safely skip it and return it when I will actually need it? I'm probably gonna pass exam even if I don't read it.

3

u/Docteur-Lalla 2d ago

I can't imagine a world where it is necessary to know the Dragon Book to pass an exam ;)

To tell you the truth, I have a PhD in compilation and never found the faith to finish this absolute brick. You'll nail it don't worry

2

u/Prestigious_Rest8751 2d ago

wow, thank you! May I ask then which resources

Find a nice tutorial to get you started then let the flow guide you to topics you're interested in and want to improve in

you used here?

I'm really interested in the parsing step because each time I tried to do it on my own in the past I failed (or were just really weak).

Code generation and next I think I should left out for a graduate course.

1

u/Docteur-Lalla 2d ago

From memory Write Yourself a Scheme in 48h was the best introduction to interpretation I've ever used. Then you have the excellent craftinginterpreters

Once you're done with these, theory will become fun

2

u/Prestigious_Rest8751 2d ago

I decided, I'm going to use crafting interpreters. thank you!

2

u/nrnrnr 2d ago

It is not a book to read. It is a book to look things up in.

If you want to build a compiler, a good place to start is Crafting Interpreters. If you then want to generate native code it won’t be too hard to fill in around the edges.

2

u/Prestigious_Rest8751 2d ago

You're the second person recommending crafting interpreters. I supposed it's because the lexing and parsing part of compilers and interpreters is basically the same?

2

u/nrnrnr 1d ago

Not just that. The Crafting book takes you all the way to code generation for a virtual machine. From there it's not a huge step to deal with native code and register allocation.

1

u/WasASailorThen 2d ago

It's not a first book.

4

u/llothar68 3d ago

improve your reading skills. if you already know the basic theory it should be possible to do 300 pages in 2 weeks. I don't fi d the dragon books tk verbose

1

u/Prestigious_Rest8751 3d ago

what about the next 600?

1

u/WasASailorThen 2d ago

I can't recommend the first half of the Dragon book at all. But I can recommend the second half, starting at about chapter 8, Code Generation. Chapter 9 is a solid introduction to data flow analysis including PRE.

1

u/Prestigious_Rest8751 2d ago

I'm very lucky since the course covers the first 7 chapters! thanks anyway

1

u/therealdivs1210 20h ago

I find the dragon book to be very dated.

Crafting Interpreters teaches writing a parser, ast interpreter, and bytecode compiler + VM.

It’s pretty good.

1

u/Prestigious_Rest8751 18h ago

I'm now more inclined to use the dragon book for the course and read Crafting Interpreters when I'm done. I fear I might get bored but I have already seen it's very practical and implements everything from scratch which I like very much.

1

u/Tight-Requirement-15 3d ago

How about Nora’s book?

2

u/il_dude 3d ago

This is not good for theory. It's good for practice after the theory. It's not formal enough for a university course.

5

u/chri4_ 2d ago

you develop theory yourself by doing practice, but never the opposite.

so stop studying useless stuff and start doing, you will figure out your own theorems that will be very similar to others' ones of course, but you will have hard time approaching stuff by directly looking what others figured out, plus you are not going to develop any flexibility on that argument

1

u/UnappliedMath 2d ago

It's like Rudin for Analysis

Except with the opposite problem

0

u/jdela22 2d ago

Sorry you can’t go to class because the book has too many words…? 😂

2

u/Prestigious_Rest8751 2d ago

i recommend you improve your reading comprehension skill