News for hackers. Stuff that matters.
Re:Build a Compiler in Five Projects by kronnpp on Tuesday November 25, 2025 @04:04AM (#46043873)
I taught in the past and still like the trilogy of books

> Modern Compiler Implementation by Andrew W. Appel

It comes in three flavors C, ML (Meta Language), and Java

https://www.cs.princeton.edu/~appel/modern/

Writing a compiler in Standard ML is as natural as writing a grammar and denotational semantics.

Compiler writing is becoming an extinct art.

Re:Build a Compiler in Five Projects by yu3zhou4 on Tuesday November 25, 2025 @05:44AM (#46044562)
Thanks!

Are you sure it’s an extinct art though? LLVM is flourishing, many interesting IRs come to life like MLIR, many ML-adjacent projects build their own compilers (PyTorch, Mojo, tinygrad), many big tech like Intel, AMD, Nvidia, Apple and others contribute to multiple different compilers, projects integrate one to another at different levels of abstraction (PyTorch -> Triton -> CUDA) - there is a lot of compilation going on from one language to another

Not to mention many languages in a mainstream that weren’t that popular 10 years ago - think Rust, Zig, Go

Re:Build a Compiler in Five Projects by pjmlp on Tuesday November 25, 2025 @09:55AM (#46046302)
You should look into GraalVM as well, as it is another approach for compiler development.
Re:Build a Compiler in Five Projects by norir on Tuesday November 25, 2025 @11:15AM (#46047272)
The prominence of LLVM is a symptom of the dying of compiler writing as an art, not evidence of its vitality.
Re:Build a Compiler in Five Projects by almostgotcaught on Tuesday November 25, 2025 @12:28PM (#46048192)
> compiler writing as an art

cooking is an art. software is engineering. no one would say "building skyscrapers as an art is dying".

Re:Build a Compiler in Five Projects by alabhyajindal on Tuesday November 25, 2025 @07:42AM (#46045259)
I heard that the ML version was a translation of the C version, and is thus not easy to follow along. Or it may have been the other way around!
Re:Build a Compiler in Five Projects by pjmlp on Tuesday November 25, 2025 @09:54AM (#46046292)
The other way around, the best book is the ML version, the other two try to do ML in the respective language.

Ironically, now with modern Java you can that much easier than the approach done in the Java variant back in 1997.

Re:Build a Compiler in Five Projects by pjmlp on Tuesday November 25, 2025 @09:58AM (#46046328)
The ML version is my favourite and I can vouch for the books being quite interesting.

For more modern folks, one can use the ML version as inspiration for doing the book exercises in OCaml, Haskell, F# or Rust.

Writing compilers for a living, and CS research is a niche domain, not something I would consider an extinct art.

Re:Build a Compiler in Five Projects by kaz-inc on Tuesday November 25, 2025 @08:34PM (#46053122)
I'll take the bait.

Do you distinguish between writing a compiler and writing an optimizing compiler, and if so, how is writing an optimizing compiler an extinct art?

Equality saturation, domination graphs, chordal register allocation, hardware-software codesign, etc there are many new avenues of research for compilers, and these are just the ones on the top of my head that are relevant to my work. Most optimization work is R&D and much of it is left unimplemented at scale, and things like the phase-ordering problem and IR validation are hard to do in practice, even given ample resources and time.