logoalt Hacker News

j2kuntoday at 5:32 PM1 replyview on HN

I took a peak at "Compiler Education Deserves a Revolution" and thought, wtf is this talking about?

It claims clang is NOT "a pipeline that runs each pass of the compiler over your entire code before shuffling its output along to the next pass."

What I think the author is talking about is primarily AST parsing and clangd, where as "any compiler tome" is still highly relevant to the actual work of building a compiler.


Replies

sigbottletoday at 8:30 PM

https://learn.microsoft.com/en-us/shows/seth-juarez/anders-h...

https://news.ycombinator.com/item?id=11685317

https://lobste.rs/s/dwf2yn/sixten_s_query_based_compiler

https://ericlippert.com/2012/06/08/red-green-trees/

Rust's salsa, etc.

Related search terms are incremental compilation and red-green trees. It's primarily an ide driven workflow (well, the original use case was driven by ides), but the principles behind it are very interesting.

You can grok the difference by thinking through, for example, the difference between invoking `g++` on the command line - include all headers, then compile object files via includes, re-do all template deduction, etc. and one where editing a single line in a single file doesn't change the entire data structure much and force entire recompilation (this doesn't need full ownership of editing either by hooking UI events or keylogging: have a directory watcher treat the file diff as a patch, and then send it to the server in patch form; the observation being that compiling an O(n) size file is often way more expensive than a program that goes through the entire file a few times and generates a patch)

AST's are similar to these kinds of trees only insofar as the underlying data structure to understand programming languages are syntax trees.

I've always wanted to get into this stuff but it's hard!