Live data from Hacker News

Tell HN: The dragon compiler book (2nd edition) is a great book

news.ycombinator.com

1–10 of 48 posts

Tell HN: The dragon compiler book (2nd edition) is a great book

#1
Hello,

I have seen a lot of people on the internet say that the dragon book is horrible book to learn compilers from.

well, I have read some of the second edition of the dragon book and I think it is a great book. The main criticism is that its too focused on parsing. Thats just like 5 chapters. I skipped these and went straight into the intermediate language, code generation, and optimizing chapters.

These chapters give a detailed account of things such as register allocation, instruction selection, and instruction scheduling. The optimizing chapters are also good.

im not claiming im an expert compiler person. I am not but compilers is something i want to learn and so i gave the dragon book a try and i really liked it.

more importantly the dragon book made me realize that compilers are mathematical systems in a way. the ast is tree and trees have mathematical properties but graphs are needed for register allocation, dataflow analysis for optimization. optimization is math problem.

So i think this book gave me a better understanding of the field and it made appreciate compilers.

i'd say if youre interested in compilers you can start with "essence of compilation" by dr. siek and get some experience writing compilers and then read the dragon book.

i just wanted to share my experience. i think the dragon book is a great book.

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#2
seconded.

so a lot of people say a lot of things. i like chapters 1-5 just as much as the rest, btw. it's objectively a great book, written by objectively great developers and computer scientists.

is it the best to learn from today? who can say.

you might also say we should not start the education for structural engineering by studying the Brooklyn bridge either.

but, so here we are.

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#4
From the parsers I see in the wild (not strictly speaking about compilers here), I think most programmers should definitely spend some time studying the basics of them. It’s incredible to me how people mess up parsing even the simplest of file formats or make it super complicated.

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#5
post #4

From the parsers I see in the wild (not strictly speaking about compilers here), I think most programmers should definitely spend some time studying the basics of them. It’s incredible to me how people mess up parsing even the simplest of file formats or make it super complicated.

Hi, my name is Weston, and I'm bad at parsing (and it hurts the whole time I do it because I'm just barely clever enough to do it badly/dangerously).

What else should I study besides the first 5 chapters of the 2nd edition of the dragon book?

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#6
post #5
post #4

From the parsers I see in the wild (not strictly speaking about compilers here), I think most programmers should definitely spend some time studying the basics of them. It’s incredible to me how people mess up parsing even the simplest of file formats or make it super complicated.

Hi, my name is Weston, and I'm bad at parsing (and it hurts the whole time I do it because I'm just barely clever enough to do it badly/dangerously). What else should I study besides the first 5 chapters of the 2nd edition of the dragon book?

An easy to reach for activity that usually involves parsing is stuff like Advent of Code, where there is almost always a parsing step.

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#7
post #4

From the parsers I see in the wild (not strictly speaking about compilers here), I think most programmers should definitely spend some time studying the basics of them. It’s incredible to me how people mess up parsing even the simplest of file formats or make it super complicated.

I'm having flashbacks to a well funded startup I used to work at. People seemed to think that to how to handle having commas in data while still being able to use CSV files was an area of active research. At, like, a dozen different layers in the application we would strip commas from any and all strings, but they would still frequently slip through and screw up the entire pipeline. The complaints I made about this quickly used up what little political capital I had. The joys of `str.split ','` based CSV "parsing".

Re: Tell HN: The dragon compiler book (2nd edition) is a great book

#10
Amen. This is will have a permanent place in my bookshelf. I actually found that implementing some of the papers was very valuable (and joyful). Not only that this stuff points you to a lot more research generated after the book. Even better is that each paper you implement imo was very self contained on its own so you can build and use as you go.
Post reply on HN