14 ms·
Writing an Interpreter in Go: The Paperback Edition
- vortegne 10y agoI 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 10y agoIt makes me really happy to read that. Not because you want to buy two editions, but because you apparently enjoyed the book a lot :)
- baconomatic 10y agoI wish I would've waited to buy that, print would've been much better!
- autoreleasepool 10y agoReally? I find ebooks side by side a terminal a much more efficient way of going through a text like this
- baconomatic 10y agoI agree, but sometimes it's nice to unplug and just look through books.
- tfryman 10y agoI didn't see it anywhere, but does the print version come with the PDF version too?
- misternugget 10y agoAuthor 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.
- Zikes 10y agoVery timely! I'm in the early stages of writing a custom interpreter in Go, so this is perfect for me.
- zerr 10y agoIt 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).
- Philipp__ 10y agoI 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.
- happy-go-lucky 10y agoMy 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.
- zerr 10y agoThe best learning outcomes for the author I believe. But I'm more interested in the prospective reader's PoV.
- tonyedgecombe 10y agoI think it's probably both, once you know a subject well it's easy to take some of that knowledge for granted. If you have just learnt it then you probably have a little more empathy for the reader.
- misternugget 10y agoI recently read a comment (I think it might have been on HN, but I can't find it) that said something like this: if you recently learned/mastered a topic, you're in a far better position to teach that topic than an expert, who's so deep into it, that they can't understand the beginners. I wish I could find the source for this, because it was much better put, but that comment contains the gist of my motivation behind writing the book.
- orloffm 10y agoSo what was the source format? Markdown?
- misternugget 10y agoYes. 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.
- orloffm 10y agoThanks.
- BlackjackCF 10y agoI'm definitely buying this. Still working my way through the PDF version, and it's just so well-written and helpful!
- joshbaptiste 10y agoPurchased an ebook copy (jfltech), while I will likely use Nim for my future toy language, this will help me immensely.
- AYBABTME 10y agoAnyone can share what sort of interpreter this is? Is it a walking-AST kind of thing, or something more advanced?
- misternugget 10y agoIt's a AST walking interpreter, completely built from scratch, including the lexer, the parser, the AST and, of course, the walking/evaluation step.
- AYBABTME 10y agoCool, asking because the level _past_ the AST walking is where I'm at personally in my learnings. I feel most treatments stop at the AST interpreter step, which is what most people see in school already. I wish there was equally good treatment for everything that comes after that. Type systems, bytecode generation, JIT, optimization phases, etc.
- abecedarius 10y agoLisp in Small Pieces is pretty good for that.
- AYBABTME 10y agoCool I'll check it out!
- msangi 10y agoPart of this should be covered by the upcoming chapters of http://www.craftinginterpreters.com/ http://www.craftinginterpreters.com/
- curun1r 10y agoI'm not sure if this is what you're after, since it's not really in book form, but I've learned a lot about advanced language implementation from reading the Rust RFCs [1], especially those relating to MIR. Between the discussion on each PR and the resulting implementation in the actual compiler, it makes some very complicated subjects more relatable than they normally would be. I'm really grateful that so much of Rust's development happens in such an open fashion. [1] https://github.com/rust-lang/rfcs https://github.com/rust-lang/rfcs
- xenihn 10y agoI 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?
- roberte3 10y agoThis book is a pretty good tutorial on getting web service with rest up and running. https://www.manning.com/books/go-web-programming https://www.manning.com/books/go-web-programming
- betodelrio 10y agoInteresting. I would like to purchase the PDF version. Is there a PROMO CODE available?
- munificent 10y agoOrdered my copy. :)
- wjh_ 10y agoI think I might be buying this, seems like a good book! Have never heard of it before.
- Entangled 10y agoMonkey 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 10y agoYes, 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.
- WaxProlix 10y agoI don't think that's true - \t happens at the beginning of every line in a block, often more than once, whereas BLOCK_STARTS and BLOCK_ENDS tokens are pretty easy to track with a stack or whathaveyou.
- coldtea 10y agoOf course you'll check the context too. But the same is also true for "{" occurs in many places with different meaning -- in struts, inside text strings, in interfaces (in Go), etc. Besides it's not the \t that you need to find as a marker for e.g. scope start. Python has "def xxx():" for example, so you see that and you know you're in a function declaration scope, same way function (xxx) { in C works. After you see that you only need to keep track of \t or " " in the beginning of lines (before any other character) to know whether you're still in the same scope or not. That's why you can't just have arbitrary whitespace count in Python lines, but you need to maintain the same "indent" in the same scope.
- rargulati 10y agoJust 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?
- deleted 10y ago[deleted]
- dom96 10y agoThis 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 10y agoI 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 :)
- wwweston 10y agoWell, if there's anything that might lure me back to Go, it's an escape hatch into another language. :b
- swah 10y agoI've been recently writing a web app in Go - I like the libraries and the tools - but when pausing to write a test script in python I immediately realized Go can't be the right tool for regular CRUD websites. Python is a joy, I love dynamic patterns when writing code. Dicts and strings! It flows... So, yay escape hatches! At some point it was going to be a pattern (Java + jruby/ola bini's language)...
- staticassertion 10y agoI 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 10y agoFunny, 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.
- staticassertion 10y agoI'm used to it I guess. Got &'a str all over my code.
- jalfresi 10y ago"... the language is drop dead boring" I LOVE boring
- zerr 10y ago"A language that doesn't affect the way you think about programming, is not worth knowing."
- staticassertion 10y agoI would say that while Go is boring, it is worth learning. It may not be anything too new or interesting but it'll likely change how you think about programming at least a bit - concurrency and error handling in Go are particularly accessible while still being different enough to change how you think about the concepts. I say that as someone who really isn't a fan of the language.
- joemi 10y agoAre 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 10y agoI 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?
- joemi 10y agoGiven that it was a few years ago, I can't be certain, but I'm pretty sure I only saw paperbacks.
- misternugget 10y agoI'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.
- skybrian 10y agoIs the complete version on Github somewhere? (I just want to skim through the source code.)
- misternugget 10y agoI 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 https://github.com/RyanBrushett/interpreter
- morboX 10y agoI like that Monkey language.
- spraak 10y agoDoes anyone have some resources or examples of writing a Scheme in Go?
- archevel 10y agoI have been writing one available at https://github.com/archevel/ghoul https://github.com/archevel/ghoul it is not finished in any way shape or form. I'm currently rewriting the evaluator to do tail call optimization in my spare time and when that's done I'll work on handling macros. If you want a more complete one you could check out zygomys https://github.com/glycerine/zygomys https://github.com/glycerine/zygomys
- spraak 10y agoThank you!
- TurboHaskal 10y agoA printed Go book with full-color syntax highlighting? Heresy! Ordered the non dead tree version as the sample chapter is of great quality.
- codewritinfool 10y agoI bought the PDF. Looks great so far!