Best practical compiler book?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Best practical compiler book?

Post 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...)
Last edited by kutkloon7 on Tue Jul 29, 2014 10:57 am, edited 1 time in total.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Best practical compiler book?

Post 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 :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
iansjack
Member
Member
Posts: 4683
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Best practical compiler book?

Post by iansjack »

The online course that was referenced here recently is worth a look: http://forum.osdev.org/viewtopic.php?f=13&t=27830
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: Best practical compiler book?

Post 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).
Last edited by kutkloon7 on Tue Jul 29, 2014 10:59 am, edited 2 times in total.
User avatar
AndrewAPrice
Member
Member
Posts: 2298
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Best practical compiler book?

Post by AndrewAPrice »

kutkloon7 - Please don't post links that infringe copyright. The Dragon Book you linked to is still in print.
My OS is Perception.
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: Best practical compiler book?

Post 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.
User avatar
AndrewAPrice
Member
Member
Posts: 2298
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Best practical compiler book?

Post 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.
My OS is Perception.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Best practical compiler book?

Post 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. :)
User avatar
AndrewAPrice
Member
Member
Posts: 2298
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Best practical compiler book?

Post 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. :)
My OS is Perception.
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: Best practical compiler book?

Post 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 :P
Btw, I found everything horribly overpriced in america (california to be exact), even if you just rent the books for one quarter.
carstenkuckuk
Posts: 7
Joined: Fri Aug 08, 2014 9:36 am

Re: Best practical compiler book?

Post 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.
Icee
Member
Member
Posts: 100
Joined: Wed Jan 08, 2014 8:41 am
Location: Moscow, Russia

Re: Best practical compiler book?

Post 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.
Post Reply