
GNU Compiler Collection Internals [pdf] - rvz
https://gcc.gnu.org/onlinedocs/gccint.pdf
======
pcr910303
As I believe that there are a lot of compiler people around at HN, I would
like to ask:

What would be a good starting point to learn about writing compilers? I have
written a small tree-walk language (and is following the byte-code based
language) following Crafting Interpreters[0], but I would like some more
learning resources.

I would ideally like some online book (I prefer readable resources) that are
similar style with Crafting Interpreters, but more focusing on compilers &
optimizing. I have heard about the Dragon book, but it was too big and pricey
:-(, I'm not sure if I can go through the entire book.

[0]: [http://craftinginterpreters.com](http://craftinginterpreters.com)

~~~
protomikron
My humble opinion: _do not_ get the Dragon book - it puts too much focus on
parser theory and implementation which is in my opinion not the hard part of
compiler construction.

Most modern languages use a handwritten recursive descent parser anyway and
the interesting part starts after you have the AST (code generation and
register allocation).

~~~
chrisseaton
> My humble opinion: do not get the Dragon book - it puts too much focus on
> parser theory and implementation

This is my strong opinion as well. Almost everyone fixates on parsing.

I've been working on an interpreter/compiler full time since 2013, so coming
up for eight years. I think I've spent maybe three or four days working on the
parser. It's a vanishingly small part of the job.

I wish compiler courses started with an AST, and then parsing was a separate
course unrelated to compilers.

~~~
CalChris
Yes. A lot of one semester compiler classes spend way too much time on lexing
and parsing. Amusingly, their coverage of parsing is limited to LALR. It
almost seems as if profs are thinking, if I had to suffer through LALR(1)
table generation then you're going to have suffer through it as well.

By comparison, at Berkeley they recreate 61C Machine Structures every few
years. Out goes the unimportant, in comes the new.

Lexing and parsing isn't even a vanishingly small part of the job. It's
usually someone else's job. Someone who works on LLVM code generation for the
XYZ processor is the wrong person to keep the Clang front end up to date with
the latest C++ committee's standard iteration.

They should push DFAs and grammars into theory classes. That said, I do like
the 2nd edition of the Dragon book, particularly the later chapters.

~~~
jcranmer
In my experience, compilers are taught over three semesters or so:
lexing/parsing is one course (or rolled into a prerequisite), the standard
compilers is the second, and advanced (graduate-level) compilers is the third
course.

~~~
CalChris
Berkeley just has CS164 [1] which is all in one. They haven't taught a
graduate compiler section in years (decades?). Stanford is on the quarter
system. They have an even more compressed single quarter compiler class, CS143
[2], but they also have a graduate advanced topics class, CS243 [3] as well.
Moreover, CS243 _doesn 't_ require 143 as a prerequisite. As an aside,
Berkeley is very strong at computer architecture (RISC, RISC-V, ...) while
Stanford is very strong at compilers (Aiken, Lam, Ullman, Hennessy, ...)

[http://www-inst.eecs.berkeley.edu/~cs164/sp19/](http://www-
inst.eecs.berkeley.edu/~cs164/sp19/)
[https://web.stanford.edu/class/cs143/index2018.html](https://web.stanford.edu/class/cs143/index2018.html)
[https://suif.stanford.edu/~courses/cs243/](https://suif.stanford.edu/~courses/cs243/)

------
saagarjha
Is this document under source control? I'm curious to see what's changed.

~~~
afraca
In case you're worried this is outdated, note this is for version 10 of gcc
(pdf is a pre-release) as stated on the frontpage of the document. I am
curious how they plan to keep this updated, I could not easily find the
repository for this.

~~~
throwaway8941
[https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/doc/gccint.t...](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/doc/gccint.texi;h=99ec005e96734f4793b9a9921541fffcb34990ac;hb=1265aa8f7e935bb506fded0a080bae5dfa2eb4c7)

------
fs111
What were RMS contributions in the last decade or so? It seems wrong that his
name is on the frontpage of the documentation and nobody elses.

~~~
saagarjha
Other contributors are listed near the end of the document, under
"Contributors to GCC".

