July 11th, 2024

'Writing a C Compiler' is a book

The "Writing a C Compiler" series transitions into a book by No Starch Press, focusing on building a C compiler with practical guidance, pseudocode examples, and essential compiler concepts for a broad audience.

Read original articleLink Icon
'Writing a C Compiler' is a book

The "Writing a C Compiler" series has been transformed into a book titled "Writing a C Compiler: Build a Real Programming Language from Scratch," set to be released by No Starch Press in late 2023. The book offers a hands-on guide to creating a C compiler, starting from compiling a basic C program to x64 assembly and gradually adding new features in each chapter. It aims to make the process accessible to a wide audience by presenting the implementation code in pseudocode, allowing readers to implement their compiler in any language. The book covers fundamental topics such as expressions, variables, control flow statements, function calls, various types like floating-point numbers, arrays, pointers, and structs, as well as classic optimizations including constant folding, dead code elimination, and register allocation. The author highlights the need for a new intermediate representation in the book, diverging from the original series, and mentions that the blog series will not continue. Despite the delay in the release date, readers who have preordered are assured that efforts are being made to deliver a comprehensive and valuable resource.

Link Icon 3 comments
By @trealira - 4 months
The post is from 2022.

However, looking at the table of contents [0], she seems to spend a lot of the book on types and pointers. That's cool, since the compiler books that I've seen don't cover languages with pointers and pointer arithmetic (and the analyses that come with that), or representations of types.

[0]: https://nostarch.com/writing-c-compiler

By @jimsimmons - 4 months
Advertising it as Writing a C Compiler is misleading. This is no where near C's speed. It's just an implementation of a C like language. And honestly there are better books or tutorials for something like that.

C's selling point is performance and portability and this book covers neither