Page 1 of 1
Best practical compiler book?
Posted: Tue Jul 29, 2014 5:22 am
by kutkloon7
Hi. I'm interested in compilers and I have the Dragon book. The book is a little bit theoretical though, not an easy read (but good as a reference though). I have read
'Let's build a compiler!' by Jack Crenshaw as well, but this is completely on the other side of the spectrum: it shows you how to build a 'toy'-ish compiler (without even using, for example, register allocation, whioch is a really standard technique for compilers). I was wondering if there are any good works 'between' this, in terms of focus on practice, maturity of the compiler you're building, easyness to read, parsing techniques (Crenshaws work uses only one limited method of parsing, it was top-down recursive descent parsing, if I'm correct)...
Or should I just go ahead and start building a simple compiler like the one in Crenshaw's tutorial? (Anyway, I'd probably have the same question after I did that...)
Re: Best practical compiler book?
Posted: Tue Jul 29, 2014 5:40 am
by Combuster
Most theory can only be practised nicely by doing it at least once. I had compiler techniques in a 10-lesson university course, and the
theory on itself is subsequently about as dry as any other theoretical literature you'll find on it. Nevertheless having to do the practical assignments goes to show you how the things are supposed to work. And if you just dig deep into it, you'll be likely to encounter those problems that a good book will have a chapter dedicated to it - after all, the writer must have gotten his own experience from
somewhere.
At least you remember roughly 4 times more from what you actually do than what you just read
Re: Best practical compiler book?
Posted: Tue Jul 29, 2014 6:09 am
by iansjack
The online course that was referenced here recently is worth a look:
http://forum.osdev.org/viewtopic.php?f=13&t=27830
Re: Best practical compiler book?
Posted: Tue Jul 29, 2014 7:13 am
by kutkloon7
Thanks, looks interesting on first sight
In the meantime I did some googling and found some relevant sources.
A good resource I just found is a little essay called
An Incremental Approach to Compiler Construction.
It's basically the perfect read when you don't where to start (together with
Let's build a compiler, which I mentioned earlier and is more appropriate as a first hands-on introduction to compilers)
Some other, more advanced works (that resemble the classic Dragon Book a lot more) are:
Understanding and writing compilers
Basics of compiler design
Compiler construction and
another one with the same title
Modern Compiler Design
These are the ones that seemed most useful after a first glance. The last six resources all seem to cover more or less the same topics and somewhat resemble the Dragon Book in selection of topics: the difference is that the Dragon Book is more of a 'complete reference'-thing: it is about 1000 pages. This goes for all but the last one: this is a solid read containing 800+ pages. There are of course more complete lists with references to compiler construction resources, these are the ones that look useful to me (and other with similar programming experience).
My plan is to read/skim though some of the shorther resources and, when I feel certain about myself, actually implement a compiler for a simple language (but we all know that this is easier to say than to actually do, so this may take some years or never happen at all).
Re: Best practical compiler book?
Posted: Tue Jul 29, 2014 10:23 am
by AndrewAPrice
kutkloon7 - Please don't post links that infringe copyright. The Dragon Book you linked to is
still in print.
Re: Best practical compiler book?
Posted: Tue Jul 29, 2014 10:59 am
by kutkloon7
Point taken! It was so easy to find that I thought the upload must be legal. Same goes for the book under the name 'modern compiler design' (not the one that's still in the post), that one looks like it's still in print too. Deleted the links from the post.
Re: Best practical compiler book?
Posted: Tue Aug 05, 2014 12:39 pm
by AndrewAPrice
My copy of the dragon book just arrived. It is a wonderful source and I would recommend it to anybody interested in compiler development. I purchased the international edition - the American edition is horribly overpriced.
Re: Best practical compiler book?
Posted: Tue Aug 05, 2014 1:56 pm
by alexfru
MessiahAndrw wrote:
Please don't post links that infringe copyright. The Dragon Book you linked to is still in print.
followed by
MessiahAndrw wrote:
My copy of the dragon book just arrived. ... I purchased the international edition - the American edition is horribly overpriced.
made me chuckle.
Re: Best practical compiler book?
Posted: Tue Aug 05, 2014 3:41 pm
by AndrewAPrice
@alexfru - LOL. I was thinking it sounds contradictory. If it helps my argument, despite the country I'm currently residing in (US), I'm Australian. I'm going to one day take the international version back with me.
Re: Best practical compiler book?
Posted: Tue Aug 05, 2014 5:32 pm
by kutkloon7
Nothing wrong with the international version! I don't even know why you would buy the expensive version. For a bike, buying an expensive one would make sense, for a book, not so much
Btw, I found everything horribly overpriced in america (california to be exact), even if you just rent the books for one quarter.
Re: Best practical compiler book?
Posted: Fri Aug 08, 2014 9:57 am
by carstenkuckuk
My first contact to compiler construction was Niklaus Wirth's "Compiler Construction", 1986, Teubner Verlag. I read it when I still was in High School, and then a friend and I implemented a Pascal compiler. The nice thing about this book is that it's small, and comes without all the complications that the Aho/Hopcroft/Ulman/Sethi add. It teaches you the basics, and then you can just dive in. After that, I'd suggest that you get your hands on Knuth's article about attribute grammars. These two documents are a solid foundation. From there you can go to the other books and fill in the details you are interested in. I strongly suggest that you hand-code your first entire compiler (including scanner and parser) for the learning effect. Once you have done that, you might want to take a look at ANTLR. The problem with ANTLR is, that you need to buy the physical book, and that you're locked into Java as the implementation language with the latest version.
Re: Best practical compiler book?
Posted: Wed Aug 13, 2014 6:04 am
by Icee
Hi kutkloon7,
If you are interested in more advanced code optimization and generation techniques presented together with the mandatory mathematical background, take a look at
Advanced Compiler Design & Implementation by Steven Muchnick. The book does not talk much about the basics like lexers, scanners and symbol tables but instead focuses on what happens once you have an internal representation of the input program, i.e. the middle- and the back-end of the compiler.