Writing A Compiler In Go
S**N
Great coverage of the fundamentals of bytecode generation and execution
The book picks up where the previous book, "Writing an Interpreter in Go", left off. The author takes an AST tree produced by the same parser that serves the Interpreter, and builds a bytecode out of it to later feed into a bytecode execution engine that is built in parallel. The book gives the reader all necessary background about the workings of a stack machine, and goes on to building one. The reader then learns about stack maintenance during normal execution flow, as well as calling functions, where the importance of agreeing on a calling convention (passing arguments, returning a value, allocating local variables) is paramount. Another important concept is delayed patching of the code that's been generated to get the conditional and unconditional jump instructions to have correct operands - those come into play while processing if() conditions. At times, the code seems somewhat hackish, but still illustrates the points author tries to explain.My only problem is with the Kindle edition, as that it appears to have lost some stack diagrams that were supposed to further illustrate the material discussed. I'm attaching a screenshot from the online reader where there's clearly a picture missing from the page. There are a few of such places - not many, maybe 3-4 or so.
K**R
Very easy to follow, code works as advertized
I have both the waiig and the wacig books. I followed both books and entered the code myself. It took me about 2 months to finish the books and code in sequence. (It's important that you follow them in sequence.)The compiler book went much faster because the basics are the same as the interpreter book. Instead of tree-walk to eval, the compiler emits instructions for the vm to execute. Since early in my career I was an assembly language programmer. The vm's stack architecture is quite natural to me so the vm portion, though new, was easy for me to follow as well.Both books are wonderfully written. Code in both book work as advertised. I enjoyed reading and following the code immensely.Ever since I left school I wanted to someday write a compiler. I did it! :-) . I am thinking about re-implementing the programs in Python. That should be quite fun, I would think.
J**M
A beautiful text
This book is incredible. I've studied making programming languages over the years as a hobbyist because I enjoy it and this book has been tremendously helpful in getting my own language up and going.It's super easy to read and not weighed down by theory. It's like the practical, up-to-date version of the Dragon book. If I was trapped on an island and forced to build a programming language (hint hint!), this is the only book I would take.
I**I
Wow, I am writing a Compiler!
I absolutely love this book and I love you! The question of interpreters and compilers have puzzled me for a while and I always wanted to know the process of creating my own language. This book provides that instruction and pulls it all into one place so that you do not have to run around the internet trying to make sense of the intricacies related to this often complex study. Thank you for your great work!
N**L
Extremely well written
Explains a complex subject very well. It does not focus heavily on theory like the “dragon” book, but provides a pragmatic basis to build on.
X**U
Great Book
yes
F**N
Oops Thorsten Ball did it again
“Writing a compiler in Go” is as good as his first book “Writing an interpreter in Go” and it was a very tall order.What’s very unique about both books is that they make complex, intimidating problems approachable. Better still, they’re not doing that by pretending it’s a simple topic or by denying or hiding its complexity.Rather than a steep learning curve, the author makes it feel like a walk in the park by slicing it in tiny (digestible) chunks and presenting them in the order that makes the most logical sense. At the end, you will gain the same knowledge as the one you would have gained from more demanding books except that it will be a far more enjoyable experience.So whether you are an experienced programmer or just curious about those things, you will be a better programmer (and possibly writer/teacher) after reading the book.I would be as bold as to say that even if you don’t really know/appreciate Go (which would be a shame) you could learn a lot even if you were to end-up implementing the code in the language of your choice.I’m very much looking forward to volumes 3 and 4 : “Writing a micro-processor in VHDL” and “Writing an operating system in Monkey”.
S**N
So THAT's how compilers work
This is a great book for understanding the inner parts of a compiler, especially if:1. You are already a programmer2. You code along in Go (no previous Go knowledge needed)3. You have some interest in compilersIt is very hands on, and you need to work from beginning to end of the book, which is not how technical books on computers usually work. I found it rewarding getting feedback when the code I had copied actually worked as I went along.It is not a comprehensive book about all the various ways a compiler can be written.
S**F
Sehr guter Einstieg
Das Buch ist ein guter Einstieg in die Thematik und verfolgt dabei, wie bereits der erste Teil, einen sehr praktischen Ansatz. Ich kannte Go vorher nur sporadisch und konnte den Code dennoch gut verstehen. Für die die sich weitergehende für das Thema interessieren empfehle ich auch einen Blick auf Crafting Interpreters von Bob Nystrom zu werfen. Hier wird ein ähnlicher Ansatz verfolgt, wobei sich das Buch in vielen Kleinigkeiten unterscheidet. In Kombination mit diesem Buch erhält man so noch ein paar mehr Ideen zur praktischen Umsetzung von Interpretern und VM Compilern.
F**N
Coup de maitre
« Writing a compiler in Go » est le digne successeur de “Writing an interpreter in Go” et le talent de l’auteur pour rendre simple des choses complexes ne se dément pas.Comme pour le premier opus, le cheminement est extrêmement progressif (sans pour autant prendre de raccourcis) et le style très agréable.A la fin du livre vous aurez réellement écris 100% d’un compilateur (byte code et machine virtuelle) sans utiliser aucun outil externe et aucune librairie autre qu’une toute petite portion de la librairie standard Go.Même si vous ne pratiquez pas ou n’aimez pas Go (ce qui serait vraiment dommage), vous pouvez faire abstraction du langage utilisé, ce livre reste un des rares ouvrages accessible sur le sujet et rien ne vous empêche de porter le code dans votre langage préféré (quelqu’un la fait pour Rust sur le premier volume).J’ai vraiment hâte de découvrir ce que sera son prochain livre. Suggestions (improbables) : « Writing a micro-processor in VHDL » ?!? « Writing an operating system in Monkey » ?!?
Trustpilot
1 week ago
3 weeks ago