by Alfred V. Aho
ISBN: 0321486811
Buy on Amazon
Found in 17 comments on Hacker News
Structure and Interpretation of Computer Programs is a classic book to start and where many started.

https://mitp-content-server.mit.edu/books/content/sectbyfn/b...

Video lectures around the course as well

https://ocw.mit.edu/courses/6-001-structure-and-interpretati...

MIT keeps a lot of course materials available online. I like to go through syllabi for text ideas for example.

https://people.csail.mit.edu/feser/pld-s23/

https://ocw.mit.edu/courses/6-035-computer-language-engineer...

Let's Build a Compiler

https://compilers.iecc.com/crenshaw/

Introduction to Compilers and Language Design

https://www3.nd.edu/~dthain/compilerbook/

Dragon book is where I started, but it's getting long in the tooth. Still a classic

https://www.amazon.com/Compilers-Principles-Techniques-Tools...

chubot · 2023-11-15 · Original thread
I have the second edition, copyright 2007, and chapter 6 is "intermediate code generation". The whole chapter is definitely not about type checking -- is yours?

https://www.amazon.com/Compilers-Principles-Techniques-Tools...

It has 11 sub-sections, 2 of which are about type checking

6.3 - Types and Declarations, pages 370-378

6.5 - Type Checking - pages 386 - 398

So that's about 20 pages out of 993 pages. A fraction of a chapter!

---

What I was referring to is the appendix "A Complete Front End", which contains a lexer and parser, but not a type checker! Doesn't sound complete to me.

I guess they have a pass to create the three-address code, and type checking is only in service of that. But they don't give you the source code!

---

Also weirdly, when you look at the intro chapter "The structure of a compiler", it goes

1.2.2 Syntax Analysis

1.2.3 Semantic Analysis (3 paragraphs that mentions type checking and coercions)

1.2.4 Intermediate Code Generation

But when you look at the chapters, there's NO semantic analysis chapter! It goes from (4) Syntax analysis, (5) Syntax-directed translation, to (6) intermediate code generation.

I think there's a missing chapter! (or two)

WalterBright · 2021-10-20 · Original thread
Writing games are a really fun way to learn to program. The best way to learn how is to find an open source game that you like, figure out how to build it, then start modifying the game to your personal taste.

Learning the basics of writing compilers will be surprisingly helpful for all kinds of programming tasks. The Dragon Book is the best:

https://www.amazon.com/Compilers-Principles-Techniques-Tools...

Too bad the prices are so high for it. The original version is much cheaper:

https://www.amazon.com/Principles-Compiler-Addison-Wesley-in...

Learning calculus is a great way to train your mind to think better.

Rochus · 2021-04-24 · Original thread
There is a more recent edition of "Compilers: Principles, Techniques, and Tools" worth considering: https://www.amazon.com/Compilers-Principles-Techniques-Tools....
wenc · 2017-09-05 · Original thread
You'll want the Dragon Book as a reference, not necessary to get started with, but to build the semantic tree on which you will need to pin concepts on. https://www.amazon.com/Compilers-Principles-Techniques-Tools...

If you aren't yet committed to any language, you can start building a parser with PyParsing. It's really easy. http://pyparsing.wikispaces.com/

If you want to take a quick (albeit expensive) class on it, Dave Beazley offers one: http://www.dabeaz.com/chicago/compiler.html

dvt · 2017-09-04 · Original thread
I strongly suggest you build something esoteric and fun first. This should be a "bare minimum" VM or interpreter. Here's one of mine that I wrote like a 8 years ago[1]: https://github.com/dvx/zeded/

Don't start off with YACC/Bison as they hide a lot of stuff under the hood. It's cool learning things from scratch. The most commonly-suggested book on compilers is known as the Dragon Book[2] and if you want to take this endeavour seriously, you should really get a copy.

[1] https://code.google.com/archive/p/zeded/

[2] https://www.amazon.com/Compilers-Principles-Techniques-Tools...

thaumasiotes · 2017-03-10 · Original thread
I used the dragon book (2nd edition) - https://www.amazon.com/Compilers-Principles-Techniques-Tools...

That proof isn't a problem in the book; it's mentioned, with a hint for those inclined to derive it themselves, in the running text.

metaobject · 2016-07-25 · Original thread
In 2006 a second edition of the dragon book was released: https://www.amazon.com/Compilers-Principles-Techniques-Tools...
theWold · 2016-01-07 · Original thread
There are many different styles and paths to learning 'Computer Science'.

But if what you are after is insight into how a computer works I found that I had my 'ah-ha' moment while learning C, Assembly (intel), and writing a compiler. I did have to have a slight basis in computer architecture, but that compiler project I worked on made everything click.

(side note on writing a compiler. Read, Decode, Execute. There are no short cuts around those series of steps).

If you are looking for a book I would recommend the 'Dragon Book'

http://www.amazon.com/Compilers-Principles-Techniques-Tools-...

I found a paper copy of the international version for cheap (like $10 US if I remember) that was amazing.

peterkelly · 2015-12-14 · Original thread
For anyone interested in compiler writing and looking for a good resource to start, probably one of the best is the "Dragon Book":

http://www.amazon.com/Compilers-Principles-Techniques-Tools-...

I highly recommend it, but it's heavy stuff. There are probably simpler guides out there that just cover the basics.

rjbwork · 2015-12-05 · Original thread
This will get you started on the compilers side of things.

http://www.amazon.com/Compilers-Principles-Techniques-Tools-...

You can also use http://lmgtfy.com/?q=sicp for a deeper understanding of interpreted languages and language structure.

karamazov · 2015-07-13 · Original thread
I try to work through hard technical material. Personally, I enjoy both technical books and MIT OCW lectures. There were a number of courses in school that I was interested in and didn't have time for, so I've been looking at the online equivalents.

"Working through" means doing exercises and projects. Reading or watching material without applying it doesn't help.

I aim to spend an hour a day on this. It doesn't always happen, but it's a reasonable enough goal that I can find time for it most days. Occasionally, I'll take a full day to study on the weekend.

Some specific recommendations:

  books:     SICP (https://mitpress.mit.edu/sicp/)     K&R     The Art of Computer Programming (if you have lots of time)     On Lisp (http://www.paulgraham.com/onlisp.html)     Learn you a Haskell     Types and Programming Languages     CLRS     The Dragon Book (Compilers, http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811)    OCW Courses:     6.172 (High performance engineering)     6.046 (Algorithms) 
This is just what I've been interested in and is by no means comprehensive. Outside of CS, math is great to learn if you haven't studied it formally.

I've found it's best to pick a topic you know enough about to be motivated to study it, but haven't done serious work in.

gte910h · 2014-06-24 · Original thread
1> Do you have a "Real" CS degree?

If not, doing a good portion of the exercises in some books on [compilers](http://www.amazon.com/Compilers-Principles-Techniques-Tools-...), [DFAs/State Machines](http://www.amazon.com/Introduction-Theory-Computation-Michae...), Algorithms (http://www.amazon.com/Introduction-Algorithms-Thomas-H-Corme...) and theoretical programming (https://mitpress.mit.edu/sicp/full-text/book/book.html) can give you some common foundational lenses with which to see these articles

2> Learning the history of your field

Nothing informs the current state of the field more than how we got here! Learn the foundation of your field from people who lived it. The podcast [Debug](http://www.imore.com/debug) is Guy English (Creator of Napkin and other apps) along with Rene Ritchie interviewing people about the history of Cocoa and CocoaTouch

I found [this episode about AutoLayout and Key Ferry illuminating](http://www.imore.com/debug-33-ken-ferry-auto-layout-passbook...).

3> Go through early versions. Few systems START complex. Look at OLD books for EARLY versions of systems, and why old php made such silly choices is obvious (hint, they weren't that silly for what it was doing). Read books and commentary through the timeline. Understand the history of what's happening to the language, then you'll understand why you are where you are.

4> Go DOWN the stack. Understand the bottom of Objective C by reading [the open source implementation of Core Foundation and more](http://www.gnustep.org/). Also available elsewhere (and I think somewhere on Apple's Site still).

5> Do what you shouldn't! Don't ship it, but really use those implementation details to do something awesome and amazing. You'll learn tons about what's happening.

PS: To the mods, those aren't affiliate links

betterunix · 2013-11-26 · Original thread
There is not much point in writing a parser without using a parser generator. Now, if you want to know how to make a parser generator, I recommend starting here:

https://en.wikipedia.org/wiki/Shift-reduce_parsing

https://en.wikipedia.org/wiki/LALR_parser

If you want lots of detail, there is always this:

http://www.amazon.com/Compilers-Principles-Techniques-Tools-...

xtracto · 2013-07-23 · Original thread
I am not an expert in compilers, but in my undergrad compiler's class one of the things I remember the most are parsers (such as LALR). I remember having a great time implementing different types of parsers:

http://en.wikipedia.org/wiki/Category:Parsing_algorithms

I think the dragon book is the absolute reference for learning compilers:

http://www.amazon.com/Compilers-Principles-Techniques-Alfred...

ze_dude · 2010-12-25 · Original thread
(Given your mention of a career, I'm going to assume he is at the stage where he can write programs to do stuff, but wants to move to the next level.)

To get better at programming, you need to do more than learn to program (languages, semantics, frameworks, etc.): you need to learn to think link a programmer. In this, there aren't many shortcuts: it requires study and practice.

Here are some great subjects to look into to get him started:

- design patterns (http://en.wikipedia.org/wiki/Design_Patterns)

- functional programming (although this is language agnostic, I personally would suggest working through "Scala by example" http://www.scala-lang.org/sites/default/files/linuxsoft_arch...)

- meta-programming (here are some videos--with free samples--on metaprogramming in Ruby http://pragprog.com/screencasts/v-dtrubyom/the-ruby-object-m...)

- algorithms

- compilers ("the dragon book" http://www.amazon.com/dp/0321486811/?tag=stackoverfl08-20)

- testing (unit, functional, integration, etc.)

One thing that will probably help him advance a LOT is learning a language that does things completely differently than the one he's using. If he'd like to try that, this book looks good (haven't used it myself but the choice of languages is pretty good): http://pragprog.com/titles/btlang/seven-languages-in-seven-w...

Also, there are some great books on this list: http://stackoverflow.com/questions/1711/what-is-the-single-m...

I'm sure there's a lot more to be said on the subject, but that's a start off the top of my head. What he should start looking into really depends on his specific weaknesses and/or preferences.