Hacker News new | ask | show | jobs
Compiling to Assembly from Scratch: the book, released (keleshev.com)
87 points by halst 2088 days ago
7 comments

Fantastic book, and one that's much needed in the landscape of compiler learning today. Many modern compiler books (such as Torczon & Cooper's "Engineering a Compiler") take the approach of showing low-level, linear IRs rather than actual assembly- a perfectly valid approach, to be sure, but one that leaves something to be desired. While compilers are interesting, I don't learn about them because I think I'll ever write a real one- I learn about them because I want to understand more about a tool at the core of my workflow. This book won't be the be-all end-all of understanding compilation to asm, especially on x86 machines, but it taught me much that my university compilers courses and the Dragon book could not. I was a little hesitant when I saw the book was written with Typescript in mind, but after reading an earlier draft I tend to agree with the author's assessment that it works well with the material, and isn't too hard to pick up with some limited javascript experience.
Yeah, and picking a language was the hardest decision for the book. I wrote the compiler prototype for it in OCaml, but using it for the book would have narrowed its audience unnecessarily. In the end, I'm very happy with picking TypeScript: it allowed to discuss the matters of static and dynamic typing within the same language. Using Python with mypy would be another option, but then, since I wanted the source language to be a subset of the implementation language, I would have to explain parsing whitespace-sensitive code, which is tricky.
Thank you for such a favorable comparison with the classics!
Woo! Congratulations! I have really been enjoying integrating/applying what I have been learning in this book. I don't have anything to show, but it's been great to play with. Thank you for your tireless efforts, Vlad! :)
Thanks for your early support and going through the draft! I'm glad you've been enjoying it!
Great book, and very approachable compared to my university texts, but hey that was 30+ years ago ;)
I've just picked this up and Street reading the first chapter I'm very excited to read the rest! It's unusually easy to follow for a book on this subject.
Congratulations Vladimir! It is a great introduction to compilation. I like the fact that it teaches parsing combinators instead of the traditional lex/yacc tools. It is a great book to be used during a college course.
Congrats on the release! I'm working on a language myself, planning on having an ARM backend, and this book is going to be very helpful implementing that.
Great idea as book, instead to following the traditional ones with bytecodes or plain old C.

A very nice introduction into modern alternatives specially for younger generations.