top | item 47076461

(no title)

j2kun | 10 days ago

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.

discuss

order

thunderseethe|9 days ago

Yeah I was just wrong here. I was under the impression clang had a concept of a request the same way Swiftc does and that is just not true. That's my bad!

sigbottle|10 days ago

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!

j2kun|10 days ago

OK, but that is distinctly NOT what clang does... incremental compilation with clang is handled at the build system level. I can't speak for rustc, but I do know that it typically ends up going through llvm, which, contrary to the author's claims, is exactly a pipeline.