top | item 13707000

Writing an Interpreter in Go: The Paperback Edition

284 points| misternugget | 9 years ago |thorstenball.com | reply

76 comments

order
[+] staticassertion|9 years ago|reply
I bought this book and I've been using it - but I'm writing the interpreter in Rust instead of Go. I really like it, and I think Go is actually a cool language for this due to its simplicity. I had very little Go experience but the language is drop dead boring, incredibly easy to pick up.

I'd recommend it.

[+] pselbert|9 years ago|reply
Funny, I did the exact same thing!

Tried to push learning Rust via the Go examples. It has been a great exercise, but highlighted the pain of dealing with various string representations in Rust.

[+] jalfresi|9 years ago|reply
"... the language is drop dead boring"

I LOVE boring

[+] joemi|9 years ago|reply
Are createspace books still of a noticeably lesser quality printing than non-print-on-demand books? I saw a few a while (a few years?) ago, and the quality offended me, so I wrote off createspace. I'd be interested to learn that's not the case anymore.

(Just to preemptively clarify: The bad quality I mentioned was most noticeable when compared to a non-POD book. On its own, it looks OK-ish and you might not think anything of it, but when you look at it next to another book you can tell.)

The book itself seems pretty neat though! I'm a PDFs for tech books kind of guy, personally.

[+] wtbob|9 years ago|reply
I used CreateSpace for a hardback book seven years ago (LaTeX → PDF), and it came out very, very nice. Absolutely no complaints.

Was your experience with their paperbacks or hardbacks?

[+] misternugget|9 years ago|reply
I'm actually really surprised by the quality. I expected, as you put it, "non-print-on-demand" quality, but what I got has no obvious flaws or defects and a really high quality feel to it.
[+] dom96|9 years ago|reply
This is really awesome. What I love especially is that the source code is syntax highlighted, I really wish I could have gotten that for my book.
[+] misternugget|9 years ago|reply
I didn't really think about this that much before, it was more like "yeah, full colors, sure, why not?". Holding the proof copy in my hands I realized what a nice touch it was and that I haven't seen this in other programming books. Of course, the full colors come with a cost, but once I saw it, I couldn't go back to black/white :)
[+] vortegne|9 years ago|reply
I will be getting one, because I loved the book so very much. It helped me tremendously when I was implementing my own little language.
[+] misternugget|9 years ago|reply
It makes me really happy to read that. Not because you want to buy two editions, but because you apparently enjoyed the book a lot :)
[+] joshbaptiste|9 years ago|reply
Purchased an ebook copy (jfltech), while I will likely use Nim for my future toy language, this will help me immensely.
[+] Entangled|9 years ago|reply
Monkey is such a nice language, clean and syntactically lovable. I wonder if the same theory can be applied to make a space indented language like python or nim, I'd like to make one.
[+] coldtea|9 years ago|reply
Yes, it can. Space indenting is just a small change to the lexer (or overall parser).

Whether those see "\t" or "{" or "begin" it's not really different, it will be the same "BLOCK_STARTS" kind of token.

[+] zerr|9 years ago|reply
It is becoming quite popular (or maybe it was always the case?) that someone learning some topic and at the same time writing a book about it. Interesting how it affects the quality of the content (versus books authored by persons with expertise in given topics).
[+] happy-go-lucky|9 years ago|reply
My belief is that writing about a topic that one is trying to come to grips with helps ensure they achieve the best possible learning outcomes.
[+] Philipp__|9 years ago|reply
I tend not to put those two "kinds" of books in same category. I read them with hope to achieve different goals. They aren't read in the same way, but I think that is normal considering those two types.
[+] mmjaa|9 years ago|reply
I believe it was always the case. I can remember books just like this in the 70's and 80's, teaching one how to write a Pascal interpreter in C, or then a GUI system in Turbo Pascal, for example, which felt very much like this kind of introduction/tutorial to both the language, and the application of the language itself to an interesting component. Is this a Go book or a Monkey/Interpreter book? Its neither, but both.
[+] daenney|9 years ago|reply
> Interesting how it affects the quality of the content (versus books authored by persons with expertise in given topics).

How does it affect the quality? Based on what criteria and examples (ideally specifically related to this book and field)?

[+] Jun8|9 years ago|reply
"You teach best what you most need to learn."
[+] tfryman|9 years ago|reply
I didn't see it anywhere, but does the print version come with the PDF version too?
[+] misternugget|9 years ago|reply
Author here. Sadly, I can't offer digital+print bundles. I sell the digital version through Gumroad and the paperback through createspace, so I don't have to worry about printing/shipping. That makes it very easy for me to sell a paperback version, but also that much harder to offer discounts or bundles or anything, if you already purchased the eBook.
[+] BlackjackCF|9 years ago|reply
I'm definitely buying this. Still working my way through the PDF version, and it's just so well-written and helpful!
[+] AYBABTME|9 years ago|reply
Anyone can share what sort of interpreter this is? Is it a walking-AST kind of thing, or something more advanced?
[+] misternugget|9 years ago|reply
It's a AST walking interpreter, completely built from scratch, including the lexer, the parser, the AST and, of course, the walking/evaluation step.
[+] wjh_|9 years ago|reply
I think I might be buying this, seems like a good book! Have never heard of it before.
[+] rargulati|9 years ago|reply
Just got the paperback version - excited to dig into this. Signed up to the mailing list as well. Is there a central place for errata, or will that only be made available as updates to the pdf version?
[+] spraak|9 years ago|reply
Does anyone have some resources or examples of writing a Scheme in Go?
[+] xenihn|9 years ago|reply
I will definitely be grabbing a copy of this and going through it, thanks!.

Anyone have recommendations for a book or tutorial for creating a REST API with Go?

[+] TurboHaskal|9 years ago|reply
A printed Go book with full-color syntax highlighting? Heresy!

Ordered the non dead tree version as the sample chapter is of great quality.

[+] orloffm|9 years ago|reply
So what was the source format? Markdown?
[+] misternugget|9 years ago|reply
Yes. 5-6 markdown files, converted to epub, mobi, pdf and html with pandoc. I know there are better workflows, especially in regards to embedding code (my approach was simple copy and paste), but if there's one recommendation I can make it's this one: check out pandoc. It's an amazing tool.
[+] Zikes|9 years ago|reply
Very timely! I'm in the early stages of writing a custom interpreter in Go, so this is perfect for me.
[+] skybrian|9 years ago|reply
Is the complete version on Github somewhere? (I just want to skim through the source code.)
[+] misternugget|9 years ago|reply
I haven't uploaded the code to Github myself, but as of v1.3 of the book the code is MIT licensed. That means there are a lot of implementations floating around, either copied straight from the book or adapter to another language. Here's the repo of a reader who followed the book closely in Go: https://github.com/RyanBrushett/interpreter
[+] baconomatic|9 years ago|reply
I wish I would've waited to buy that, print would've been much better!
[+] autoreleasepool|9 years ago|reply
Really? I find ebooks side by side a terminal a much more efficient way of going through a text like this