OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 10:43 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 5:22 am 
Offline
Member
Member

Joined: Fri Jan 04, 2013 6:56 pm
Posts: 98
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.

Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 5:40 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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 ]


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 6:09 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
The online course that was referenced here recently is worth a look: viewtopic.php?f=13&t=27830


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 7:13 am 
Offline
Member
Member

Joined: Fri Jan 04, 2013 6:56 pm
Posts: 98
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.

Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 10:23 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
kutkloon7 - Please don't post links that infringe copyright. The Dragon Book you linked to is still in print.

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Jul 29, 2014 10:59 am 
Offline
Member
Member

Joined: Fri Jan 04, 2013 6:56 pm
Posts: 98
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.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Aug 05, 2014 12:39 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
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.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Aug 05, 2014 1:56 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
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. :)


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Aug 05, 2014 3:41 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
@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.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Tue Aug 05, 2014 5:32 pm 
Offline
Member
Member

Joined: Fri Jan 04, 2013 6:56 pm
Posts: 98
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.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Fri Aug 08, 2014 9:57 am 
Offline

Joined: Fri Aug 08, 2014 9:36 am
Posts: 7
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.


Top
 Profile  
 
 Post subject: Re: Best practical compiler book?
PostPosted: Wed Aug 13, 2014 6:04 am 
Offline
Member
Member

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 51 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group