Hacker News new | past | comments | ask | show | jobs | submit login

Don't read the dragon book if you're interested in compilers. It's lex and parse heavy, and is not up to date with more recent best practice on codegen. Further, the lex and parse end of it is focused on the kind of theory you need to build tools like lex and yacc, rather than stuff you need to know if you want to write a compiler.

For a good intro of modern back end development, check out Engineering a Compiler. It's also got the lexical and parsing end of things, but a bit better done, but still quite theoretical.

One of the best books I read on programming is "Concepts, Techniques, and Models of Computer Programming"; it's not strictly speaking language agnostic, based as it is on Oz, but Oz isn't a language you'd ever use in production and is a reasonable base to introduce you to ways of programming that will probably be completely unfamiliar, like constraint programming, dataflow, concurrent logic, etc.

Most people who criticize the Dragon (Compilers etc... by Aho et al.) book seem to focus on chapters 3 and 4 which are the chapters on lexical analysis and parsing. The book has 12 chapters. Whatever your feelings on the parsing techniques, the book covers WAY more than that. It has a really good introduction to code generation, syntax directed translation, control flow analysis, dataflow analysis, and local, global and whole program optimizations.

As someone who has quite a few books on compilers, program analysis, type theory, etc... I find the Dragon book an irreplaceable reference to this day. It has a breadth of content shared by very few other books. For instance, Muchnick's classic "Advanced Compiler Design and Implementation" is really good for analysis and optimization but neglects all front end topics. The only area where I believe the Dragon book is inadequate in is type theory (I recommend Types and Programming languages [TAPL] by Pierce and Semantics with Application by Nielson for a gentler intro).

As to parsing, its chapter on parsing (4) is not as "hip" has some people want. However, it is solid and will teach you how to do parsing. There are newer and fancier techniques not covered in Chapter 4 but in general most people would benefit just having a solid understanding of recursive descent parsing!

Don't read only the Dragon book if you're interested in compilers (or parsing in general). But it should be read, in addition to whatever else you read on the subject. It's classic for a reason.

Most programmers don't understand parsing worth a crap, imho. Some compiler theory would do most of us some good. I read it because I was doing data stream parsing back in the olden days before XML (which was before JSON), when we had to write our own stream formats. It really changed my whole way of thinking about a fundamental class of programming problems.

I found the Dragon Book unbearable---and I am one of those people interested in theory. Pick something better, plenty of choice available.

'Essentials of Programming Languages' and 'Types and Programming Languages' are good choices. (But slightly off-topic for this particular subthread, since they don't deal with parsing.)

The Dragon book is not good at teaching parsing, but is obsessed with the idea and spends 2/3 of the time talking about it, so you'll just be left thinking it's really difficult. The whole thing is extremely boring and lacks confidence.

Try "Parsing Techniques: A Practical Guide" and then a more concise book like Muchnick.

I also found my theory-of-computation course in college to be a wonderful help in understanding parsing.

Being familiar with the Chomsky Hierarchy ([1]), and the kinds of language recognizers required for each level in that hierarchy, can save parser authors a lot of wasted time.

E.g., "regex's can't count!"

[1] https://en.wikipedia.org/wiki/Chomsky_hierarchy

Hey, I seconded this, the Dragons Book is not the best textbook or introduction to the topic, there are a lot of better ones. The Dragons Book is more of a classic. If you want to read a good book on compilers construction then you're better off reading "Engineering a Compiler" by K. Cooper and L. Torczon or "Modern Compiler Implementation in ML" by A. Appel.

If you want more resources on Compilers other than books, such as tutorials, guides, talks and papers, then go ahead and check the Awesome Compilers vertical I compiled a while ago: https://github.com/aalhour/awesome-compilers


Writing a parser is broadly applicable to a wide range of problems, not just writing a compiler.

The criticism is that the strongest part of the book is focused on writing compiler compilers - that is, writing tools that write parsers - not writing parsers.

My criticism is that the book is unbearably imperative and doesn't actually teach you any of the theory well.


Wrote many for XML/json based configs.

Do note that there are multiple editions of the Dragon book and later editions have a far better codegen section.

One of the more famous compiler writers from that era once told me that the Dragon book's original codegen section wasn't even historically how anyone wrote a compiler and it certainly didn't reflect modern practice even back in the 90s.

However, the update significantly improves it with the addition of Monica Lam's contribution. I don't know if it's state of the art for codegen (probably not), but I'm not sure what book is (Muchnick is great too, but this is also quite old now).

CTMCP is awesome indeed, one of my favourite along with SICP I would say.

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