Hacker News new | past | comments | ask | show | jobs | submit login
Basics of Compiler Design (diku.dk)
158 points by cygwin98 on April 22, 2011 | hide | past | favorite | 10 comments



As I've been working on my pet compiler project recently, I began to collect some compiler-related online resources, this book is one of the hidden gems. The author (Torben Mogensen) has been so generous to give it out for free, that's why I think it needs more exposure.

It's heavy on the compiler theory part, so I mainly use it as a reference book. It also has a "companion" book (my take) -- Programming Language Concepts for Software Developers [1] by Peter Sestoft. The PLCSD book, also free, is more on hand-on projects, where you can implement a Micro-C compiler.

[1] http://www.itu.dk/courses/BPRD/E2010/plcsd-0_50.pdf


Perfect. The two together act to provide theory + practice (especially cool that PLCfSD uses F# :-)

What other resources have you found, and how do they compare? Have you read the Dragon Book? I hear it isn't actually all that wonderful in reality, though there seems to be differing opinions on that.

I have both a pet compiler project which has never really got off the ground and am attempting to contribute (albeit slowly!) to the go programming language so have a special interest :)


The intriguing part of PLCSD to me is that it uses F#, which is the language I use as the tool for my project, :)

I took compiler course during my university days, so the theory part is not a big issue to me. That's why this free book comes so handy as a reference book. I'm aware of the dragon book, tiger book, as well as, the whale book and had a quick read in bookstore. They all are good books, but I don't find my need to keep them on my bookshelf. So I don't think I am in the position to comment on them. YMMV.


I hadn't heard of a whale book -- that turns out to mean Muchnick's.


The Dragon book's weaknessess, IMO, were the code generation and optimization sections. This has been comprehensively fixed in the second edition thanks to the addition of Monica Lam as an author - her experience on the code generation side is extensive and recent.


Nifty, I actually worked a TA under Torben Mogensen recently, teaching out of this book. It's a really succinct description of the fundamental theory, although a little light on the practice.


Out of curiosity, what projects the students have to implement for the course?


They are given a functioning compiler (written in Standard ML) for a small subset of a relatively simple artificial language (a new one every year), and they have to extend the compiler to support the full language. This involves changing every level (lexing, parsing, type-checking and code generation). For the final exam, they have to add a new feature to the language.


When I did this course, you had to implement a compiler for a toy language. The language would change each year. Our compiler was for a language called "FUN". I think it was a first-order functional language with heap-allocated objects. It had to be implemeted in SML, which comes with Lex and Yacc implementations. You got various bits and pieces handed out, like register-allocation and the assembly-generator (for MIPS).

The neat thing was, that that you also had to design a simple pipelined MIPS processor and you could run (in simulation) the code your compiler generated on the architecture. This gave you a pretty good understanding of what happens from the time you write your code to it actually generating a result.


A good compiler course will have you implement a toy compiler. Here is the course I took about a decade ago by the same teacher that I took it with.

http://www.cs.sfu.ca/cc/379/shermer/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: