Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Cover of Writing a C Compiler

    Writing a C Compiler

    Nora Sandler · 2023

    A fun, hands-on guide to writing your own compiler for a real-world programming language. Compilers are at the heart of everything programmers do, yet even experienced developers find them intimidating. For those eager to truly grasp how compilers work, Writing a C Compiler dispels the mystery. This book guides you through a fun and engaging project where you’ll learn what it takes to compile a real-world programming language to actual assembly code. Writing a C Compiler will take you step by step through the process of building your own compiler for a significant subset of C—no prior experience with compiler construction or assembly code needed. Once you’ve built a working compiler for the simplest C program, you’ll add new features chapter by chapter. The algorithms in the book are all in pseudocode, so you can implement your compiler in whatever language you like. Along the way, you’ll explore key concepts like: 1. Lexing and parsing: Learn how to write a lexer and recursive descent parser that transform C code into an abstract syntax tree. 2. Program analysis: Discover how to analyze a program to understand its behavior and detect errors. 3. Code generation: Learn how to translate C language constructs like arithmetic operations, function calls, and control-flow statements into x64 assembly code. 4. Optimization techniques: Improve performance with methods like constant folding, dead store elimination, and register allocation.

    Computer Science
    Open LibraryAmazon
    Stats for nerds
    7recommend
    10mentions
    7people
    2024–2026years
    90% recommend10% neutral

    Mentions per year

    202420252026

    What Hacker News says

    1. raddanOct 2026
      You should do it. But I recommend a book or two on compiler design. There are useful techniques (like SSA) that simplify program analysis if you decide you want to dip your toes into adding optimizer passes. Building stuff yourself, the hard way, is definitely the best way to learn. I wish I had unbounded time to do it…

      Edit: I like the Appel compiler book. One of my students enjoyed “Writing a C compiler” by Nora Sandler. There are also a number of classic compiler books that feel more relevant once you are deep in the weeds.

      thread
    2. piinbinaryMay 2026
      I've been going through Nora Sandler's Writing a C Compiler book and writing a compiler in Python. I'm excited to start the chapters on optimization - those seem like the most fun algorithm problems.

      I recommend the book. It certainly isn't easy (maybe 3x harder than Crafting Interpreters), but I've learned a ton (eg how to deal with operations on different sizes of types, or the trick of using pseudoregisters to avoid having to figure out registers up front).

      https://github.com/jmikkola/writing-a-c-compiler-python

      thread
    3. asibahiApr 2026
      Inspired by Ghuloum's book is this really nice book by Nora Sandler: Writing a C Compiler https://norasandler.com/book/
      thread
    4. xqb64Feb 2026
      Yeah. My favorite are books that guide you through implementing complex systems projects from scratch, like Nora Sandler's "Writing a C compiler", or Sy Brand's "Building a Debugger". I wish they produced A LOT more of them.
      thread
    5. ceronmanSep 2025
      Very cool. I think Wasm is a nice instruction set, but I agree that its structured control flow is a bit weird and also the lack of instructions to handle the memory stack. But it's much more cleaner than something like x86_64.

      If you are interesting in learning in more detail how to write a C compiler, I highly recommend the book "Writing a C Compiler" by Nora Sandler [0]. This is a super detailed, incremental guide on how to write a C compiler. This also uses the traditional architecture of using multiple passes. It uses its own IR called Tacky and it even includes some optimization passes such as constant folding, copy propagation, dead code elimination, register allocation, etc. The book also implements much more features, including arrays, pointers, structs/unions, static variables, floating point, strings, linking to stdlib via System V ABI, and much more.

      [0] https://norasandler.com/book/

      thread
    6. JtsummersAug 2025
      If you like Ghuloum's paper, there are three fairly recent compiler books that are inspired by it:

      https://nostarch.com/writing-c-compiler - Writing a C Compiler by Nora Sandler, language agnostic for the implementation.

      https://mitpress.mit.edu/9780262047760/essentials-of-compila... - Essentials of Compilation (using Racket) by Jeremy Siek

      https://mitpress.mit.edu/9780262048248/essentials-of-compila... - Essentials of Compilation (using Python) by Jeremy Siek

      Those last two both have open access versions.

      thread

    Related

    Cover of Practical C Programming
    2010–2022

    Practical C Programming

    Steve Oualline
    7 recommend · 10
    Cover of The C Programming Language
    2007–2026

    The C Programming Language

    Brian W. Kernighan
    246 recommend · 604
    Cover of C Concurrency in Action
    2012–2025

    C Concurrency in Action

    Anthony Williams
    14 recommend · 24
    Cover of Engineering a compiler
    2007–2026

    Engineering a compiler

    Keith D. Cooper
    39 recommend · 91
    Cover of A retargetable C compiler
    2010–2026

    A retargetable C compiler

    Christopher W. Fraser
    9 recommend · 23
    Cover of Compiler design in C
    2011–2026

    Compiler design in C

    Allen I. Holub
    11 recommend · 28
    Cover of Modern compiler implementation in C
    2010–2024

    Modern compiler implementation in C

    Andrew W. Appel
    8 recommend · 13
    Cover of C programming
    2009–2025

    C programming

    K. N. King
    26 recommend · 33