-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write an (online) book about writing interpreters in Rust #7
Comments
This is a great idea, agree 100% on all points! I think this might be what #1 is missing in terms of a specific purpose and focus. As I think you mentioned in a conversation elsewhere about Inko, language-specific allocator, GC and bytecode optimizations happen, which will lead to some different Rust code patterns and tradeoffs across different languages (imperative vs purely functional as the obvious example.) However, I think the points you've outlined above are a good place to start and other language implementations could be covered later. Parsing is a well covered and less interesting topic, but it might be worthwhile to integrate all the basic-level topics - mark & sweep, bytecode interpreter loop, all on a single thread - with a simple s-expr to bytecode compiler, for completeness. That avoids syntax bikeshedding and keeps parsing as simple as possible. I would add one more topic: "Exposing access to managed-objects outside of the VM environment" for covering different ways and tradeoffs of interacting with the VM and heap in safe Rust. For arranging a book, there's also https://github.com/rust-lang-nursery/mdBook fwiw, but I don't have experience with either mdBook or GitBook. |
I've created https://github.com/rust-hosted-langs/book for editing a book in. I took a look at mdBook, it's straightforward to use and importantly, has excellent Rust code-snippet support. We can use the book label in this repo to group discussions on content. Perhaps creating one issue per chapter to cover would make sense? |
That sounds like a good plan. One thing to keep in mind is that at least early on we probably shouldn't focus too much on the organisation/structure. Doing so can lead to a lot of arguing about what goes where, without actually having any content to organise in the first place. |
Just to keep this issue consistent, discussion of book content is now on the issue tracker for the book repo: |
By providing a book of sorts (e.g. using https://www.gitbook.com/) we would solve two problems:
The book wouldn't focus on writing an interpreter from start to finish (that's a lot of work), instead it would focus more on specific patterns (e.g. how do I write an interpreter loop, how do I come up with a bytecode format, etc, etc). For the sake of keeping the scope limited we should probably start with an interpreter, but maybe over time we can also extend it to writing compilers.
Some topics to cover would be (in no particular order):
panic!
)I'm not sure if we should cover parsing. Unfortunately many of existing programming language resources fall for the trap of only covering parsing, which I think is one of the most boring parts of a programming language. It's also very easy to get stuck bike-shedding about the syntax and how to parse it, instead of just focusing on writing an interpreter/allocator/etc.
Any thoughts?
The text was updated successfully, but these errors were encountered: