6 ms·
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
by sklogic 11y ago
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
- fahadkhan 11y agoPlease could you recommend an alternative?
- landmark2 11y agoModern Compiler Implementation in C
- fao_ 11y agoBy A. Appel? I heard that the ML version is better since much of the code apparently isn't very idiomatic (It was supposedly translated directly from the ML book). I would probably recommend both that and The Dragon Book, as they cover roughly the same material but in a slightly different manner.
- Ace17 11y agoDick Grune - Modern Compiler Design
- xigency 11y agoEngineering a Compiler 2nd edition, by Keith D. Cooper and Linda Torczon The dragon books are better used as references to those who are already familiar with all of the high-level concepts in compiler writing.
- barrkel 11y agoIt's fairly heavy in lexing and parsing theory, especially around finite automata, pushdown automata, etc. It's the kind of book you might want to read if you're reimplementing yacc. Modern code generation has moved on a bit, so I wouldn't dig too deeply into the latter third or so of the book. All in all, for a hobby compiler, it would be a poor choice; heavy on unnecessary theory in the front end and outdated on on back end stuff. Let's Build a Compiler by Jack Crenshaw is one of my favourite guides for the hobbyist, although it's a bit dated now since it used Turbo Pascal and targeted 16-bit x86.
- sklogic 11y agoIt does not make any sense to reimplement yacc in the 21st century. There are far more powerful and yet simple parsing techniques, rendering all that automata stuff useless and outdated. Take a look at PEG, Pratt parsing and GLR.
- sparkie 11y agoPfft. Who wants to parse in 2015? We all know that constructing your language as a JSON schema is the way forward. Your JSON parser is the only parser you'll ever need.
- ORioN63 11y agoOr a lisp.
- wtetzner 11y agoOr even better, GLL. http://dotat.at/tmp/gll.pdf http://dotat.at/tmp/gll.pdf
- nickpsecurity 11y agoBest features of both types of parsers? Hell yeah! Never even heard of this one despite all the research updates I did a few years ago. Thanks for the link.
- sklogic 11y agoIt's an interesting one, I'll add it to my collection. Although, to be fair, PEG (Packrat) do support left recursion [1], and it can also be combined with Pratt for the binary expressions very efficiently, at O(n). [1] http://www.vpri.org/pdf/tr2007002_packrat.pdf http://www.vpri.org/pdf/tr2007002_packrat.pdf
- wtetzner 11y ago> Although, to be fair, PEG (Packrat) do support left recursion [1] Unfortunately it sometimes generates the wrong parse: http://tratt.net/laurie/research/pubs/papers/tratt__direct_left_recursive_parsing_expression_grammars.pdf http://tratt.net/laurie/research/pubs/papers/tratt__direct_l...
- deleted 11y ago[deleted]
- nickpsecurity 11y agoThere's quite a few decent alternatives. I often suggest Wirth's Compiler Construction and Oberon sources because they're straightforward lessons plus give experience with Wirth style of simple, safe, efficient languages. Then, they can improve the Oberon System or compilers for personal projects and improvement. That said, I typically recommend compilers get written in an ML or LISP given it's so much easier to do in those languages. Ocaml and Racket are my main recommendations for modern work. One can also use techniques for deriving imperative code from functional programs if one wants to re-implement that compiler in specific imperative language on a machine. The constructs are even straight-forward enough for macro assembly for those that want to understand it down to bare metal.
- sklogic 11y agoYes, functional side of things is interesting and rarely covered in the standard compilers courses. There is an old but good book, often overlooked: "Functional Programming" by Anthony J. Field and Peter G. Harrison (1988). Despite the title, it's more about various compilation techniques. Also an old but still relevant (it is missing the STG, but otherwise full of interesting stuff): http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/ http://research.microsoft.com/en-us/um/people/simonpj/papers... It also worth following this blog: https://wingolog.org/ https://wingolog.org/
- nickpsecurity 11y agoI got the 2nd link here before, maybe from you. Might be old but very thorough treatment of about every aspect of functional compilation. I have it saved in djvu and pdf in case I neet someone starting in that area. :) The other two are new to me. Thanks for those.
- urs2102 11y agoI definitely agree with ML and OCaml, but why do you recommend Lisp for compiler work? I love working withs Lisps, but how do you deal with dynamic typing bugs in compiler work? I prefer OCaml/Haskell/ML for its really strong static type checking for compiler work. Just curious though...
- hitlin37 11y agoSince technologies changes before the book is out, how does that hold in compiler domain? Are there any modern compiler book that explains around llvm/gcc as an example compiler?
- sklogic 11y agoNot sure if there are any books around LLVM or gcc, but there is a lot of up to date texts. Grune at al., "Modern Compiler Design", Appel, "Modern Compiler Implementation in ML", and many more. P.S. Because of a slow-ban, adding another one to this answer. This is the best source on SSA: http://www.cri.ensmp.fr/people/pop/papers/2006-12-thesis.pdf http://www.cri.ensmp.fr/people/pop/papers/2006-12-thesis.pdf
- sgeisenh 11y agoI'll just add this on: https://www.cs.cmu.edu/~fp/courses/15411-f14/schedule.html https://www.cs.cmu.edu/~fp/courses/15411-f14/schedule.html The lecture notes are simple and excellent, though at a very high level of abstraction. Though most of the notes are full of references to the original material, which is super nice.
- spooningtamarin 11y agoI learned compilers this way and yes, it's extremely hard. Things got so high-level that I forgot what the real problem was and kept wondering why the algorithm I wrote isn't working.
- troydj 11y agoI wouldn't go so far to say that the Dragon Book is outdated and irrelevant. (I'm assuming you're referring to the 2nd edition from 2006.) Unless you're focusing on back-end optimization and code generation techniques (something a new compiler writer typically does NOT do), the bulk of the theory and material you'd cover in a first semester compiler course is fairly static. But if a person is merely looking to bang out a compiler without getting overwhelmed with how to convert NFAs to DFAs for lexing, etc., some good alternative books are: A Retargetable C Compiler: Design and Implementation, by Hanson and Fraser (http://www.amazon.com/Retargetable-Compiler-Design-Implementation/dp/0805316701 http://www.amazon.com/Retargetable-Compiler-Design-Implement...). This book constructs and documents the explains the code for a full C compiler with a recursive descent approach (no flex/lex or bison/yacc). I have some experience augmenting this compiler, so I can vouch for the book's ability to clearly convey their design. Compiler Design in C, by Allen Holub (http://www.holub.com/software/compiler.design.in.c.html http://www.holub.com/software/compiler.design.in.c.html). Downloadable PDF at that link as well. A book from 1990 in which Holub constructs his own version of lex and yacc, and then builds a subset-C compiler which generates intermediate code. Practical Compiler Construction, by Nils Holm (http://www.lulu.com/shop/nils-m-holm/practical-compiler-construction/ebook/product-18952649.html http://www.lulu.com/shop/nils-m-holm/practical-compiler-cons...). A recent book which documents the construction of a SubC (subset of C) compiler and generates x86 code on the back end.
- sklogic 11y agoIt is actually an outdated view, to split a compiler into dedicated monolithic front-end and back-end parts. The more modern approach is very much the opposite. It is a nearly continuous, very long sequence of very simple transforms, rewriting a code seamlessly, all the way down from a front-end (i.e., a parser) to a back-end or multiple back-ends. And this approach is very alien to anything you'd find in the Dragon Book. As for parsing, as I already said elsewhere in this thread, all the techniques from Dragon Book are not practical any more and are not used in the modern compilers. There are far better ways, which are not covered in the book, and they're far simpler, not even deserving a dedicated book at all.