logoalt Hacker News

A Compiler Writing Journey

104 pointsby ibobevyesterday at 11:44 PM15 commentsview on HN

Comments

cxrtoday at 3:01 PM

(2020)

Previously:

12 comments; 156 points. 2022 November 29. <https://news.ycombinator.com/item?id=33788013>

67 comments; 484 points. 2020 January 8. <https://news.ycombinator.com/item?id=21968420>

mzstoday at 2:47 PM

"Part 64: Self-compilation on an 8-bit CPU"

Unlike how a bunch of projects end right as they start to get good, this has a great ending. Thank you

maltyxxxtoday at 11:46 AM

Worth also mentioning Crafting Interpreters by Robert Nystrom (craftinginterpreters.com) as a companion — it implements two interpreters in Java then C, covering a treewalk interpreter and a bytecode VM, and is freely available online. Together with this journey and nils-m-holm's Practical Compiler Construction mentioned above, you get a remarkably complete self-study path from parsing fundamentals all the way to code generation.

On the C vs typed language debate: C forces you to think about representation explicitly — no algebraic types to lean on, every tagged union is manual. That arguably teaches you more about what a compiler actually does structurally. But OCaml or Haskell's pattern matching makes the recursive descent so natural that it's worth attempting both if you have the time. They illuminate different things.

show 1 reply
skyfantomtoday at 1:40 PM

This hopefully can be useful as well https://space4links.com/r/writing-a-compiler

parallax_errortoday at 3:21 AM

Very cool! I can’t imagine writing everything in C, I’m currently learning this in OCaml which seems nicer for a project like this.

show 2 replies
pjmlptoday at 8:11 AM

Having it all in C brings back memories from "Compiler Design in C" a famous book for its time, printed in 1990.

https://holub.com/compiler/

show 1 reply
Muhammad523today at 2:27 PM

I feel like interpreters and compilers were trendy in 2015/2016, bu i'm too young to know. Am i right?

maniacsudiptoday at 7:19 AM

[dead]

brcmthrowawaytoday at 3:26 AM

How much of Claude was used?

show 2 replies