Live data from Hacker News

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

news.ycombinator.com

31–40 of 48 posts

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

#31
post #23
post #14

Besides devoting too many pages to parsing, I think compiler practitioners have low opinion of the book because it isn't useful for them. For example, the second edition claims to be updated to modern optimization techniques, and in a sense that's true, but it is useless because the book isn't using SSA. For practitioners, SSA is not optional these days, and everything about optimization in the book needs to be updat…

But the dragon book introduces three address code. SSA is a variant of three address code. Take a look here http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.htm... .

Well yes, but you can't use the algorithm in the dragon book to generate three address code to generate SSA, because SSA has additional constraints. The dragon book really dropped the ball here, there is no excuse why it doesn't include any algorithm for SSA construction.

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

#32
post #8

I have the first edition but do not have an intention to create compilers yet, and the book is the hardest book I have for recreational reading. I can not just open it in the middle and find anything understandable.

It’s really rewarding though when you write a compiler. I recommend the experience. But if you think about compilers are so fundamental for the whole software infrastructure. So I think compilers is worth knowing. You will understand languages better; for example you will understand how statically and dynamic languages work because you will Implement a type checker, you will understand lexical scoping better because you will compile this to assembly; and overall you will have a better idea of how your high level code looks like in assembly which could help you write efficient code.you will also get to understand how memory is laid out which will help you appreciate NGINX.so by learning compilers I think you will be appreciate more web development. Those are my thoughts anyways. I’m not saying I’m correct but that’s what I’ve noticed in my journey

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

#33
post #23
post #14

Besides devoting too many pages to parsing, I think compiler practitioners have low opinion of the book because it isn't useful for them. For example, the second edition claims to be updated to modern optimization techniques, and in a sense that's true, but it is useless because the book isn't using SSA. For practitioners, SSA is not optional these days, and everything about optimization in the book needs to be updat…

But the dragon book introduces three address code. SSA is a variant of three address code. Take a look here http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.htm... .

3AC/TAC is something fundamentally different than SSA. Sure, both somehow superficially constrain how you write variable assignment statements - if your intermediate representation contains such things and is a list of instructions. 3AC means that your "instructions" have In fact SSA makes no constraints on the number of operands in an instruction/operation what so ever.

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

#34
post #31
post #23

Earlier quoted context omitted.

But the dragon book introduces three address code. SSA is a variant of three address code. Take a look here http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.htm... .

Well yes, but you can't use the algorithm in the dragon book to generate three address code to generate SSA, because SSA has additional constraints. The dragon book really dropped the ball here, there is no excuse why it doesn't include any algorithm for SSA construction.

[deleted]

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

#35
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 q…

You don't need to complain for this, just fix the code in all places by calling a better csv parser that you can also write.

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

#36
post #33
post #23

Earlier quoted context omitted.

But the dragon book introduces three address code. SSA is a variant of three address code. Take a look here http://www.cs.columbia.edu/~aho/cs4115/Lectures/15-03-25.htm... .

3AC/TAC is something fundamentally different than SSA. Sure, both somehow superficially constrain how you write variable assignment statements - if your intermediate representation contains such things and is a list of instructions. 3AC means that your "instructions" have In fact SSA makes no constraints on the number of operands in an instruction/operation what so ever.

Three address code:

```

p = a + b

q = p-c

p = q * d

```

Ssa:

```

p1 = a+ b

q1= p1 - c

p2 = q1 * d

```

Given the above examples how is it not straightforward to use ssa instead of three address code using what the dragon book teaches? What is wrong with the above examples?

In fact section 6.2.4 in the dragon book it says:

“Two distinctive aspects distinguish SSA from three-address code. The first is that all assignments in SSA are to variables with distinct names; hence the term static single-assigment.” The second one is that ssa uses a function to combine two definitions

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

#37
post #14

Besides devoting too many pages to parsing, I think compiler practitioners have low opinion of the book because it isn't useful for them. For example, the second edition claims to be updated to modern optimization techniques, and in a sense that's true, but it is useless because the book isn't using SSA. For practitioners, SSA is not optional these days, and everything about optimization in the book needs to be updat…

Do you recommend a book that’s more up-to-date?

Tiger books include SSA, GC (tracing and RC), OOP, FP,....

https://www.cs.princeton.edu/~appel/modern/

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

#38
What is a good book just for recursive descend parsing? I dabbed into some compiler books but found BNF difficult.

Just some clarification, it is not difficult to understand but difficult to build from scratch. I'm thinking maybe a book that asks me to build up BNF expressions for a series of grammars of gradually increasing complexity would be nice.

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

#39

What is a good book just for recursive descend parsing? I dabbed into some compiler books but found BNF difficult. Just some clarification, it is not difficult to understand but difficult to build from scratch. I'm thinking maybe a book that asks me to build up BNF expressions for a series of grammars of gradually increasing complexity would be nice.

Crafting Interpreters was fun to read and easy to follow, even as someone with a mechanical engineering degree :)

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

#40

What is a good book just for recursive descend parsing? I dabbed into some compiler books but found BNF difficult. Just some clarification, it is not difficult to understand but difficult to build from scratch. I'm thinking maybe a book that asks me to build up BNF expressions for a series of grammars of gradually increasing complexity would be nice.

You might want to checkout Parsing Techniques: A Practical Guide by Dick Grune et.al.

Came across it on HN but I have not read it though.

Post reply on HN