Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

61–70 of 193 posts

Re: Crafting Interpreters

#61
post #23

Planning to read this soon. Anyone got any other compiler book recommendations? Preferably modern (I've heard the dragon book is out of date)

I’ve not read this book, so can’t offer a comparison but Thorsten Ball’s two books [1] are great. The dragon book was my textbook in college, brings back memories, might be outdated but some concepts should still be useful. [1] https://thorstenball.com/books/

Thorsten Ball's books are the closest thing to Crafting Interpreters. Not just by topic, but also with how the code is presented. By far these are among the few books I know that take the effort to guide the reader to programming something complex from scratch, while also being testable as the program grows. This means that previously presented code changes along the way as new features are added.

A lot of other "code yourself" books, on the other hand, simply slice already finished codebases, and there's no way to test a simpler incomplete version of the program unless the reader makes extra effort and go beyond what is presented in the book.

While there is a lot of overlapping topics in Nystrom's and Ball's books, there are also enough differences to learn something new from the other. Ball's books uses the same parser and AST as front ends to both tree-walking and VM interpreter. CI, on the other hand, skips the AST for the VM interpreter, and also teaches extra topics like implementing garbage collection, dictionaries/hashtables and class-based OOP.

Re: Crafting Interpreters

#62

I really wish this book used something other than Java. Nothing against Java - just that I don't know it and don't feel excited about learning it.

Java is pretty readable, as long as your familiar with C-style languages you shouldn't have too many problems rewriting this in another language.

Re: Crafting Interpreters

#63
post #56

Does anyone know of a good resoucce for creating a statically typed language with stuff like parametric polymorphism and basic type inference?

Modern compiler implementation in ML by A. W. Appel

There are (inferior) versions of the same in C and Java. I'd use them together with the ML version.

Re: Crafting Interpreters

#65

Earlier quoted context omitted.

When Java gets pattern matching, it will become a more reasonable choice to write an interpreter in.

It’s had pattern matching since 16, it’s been expanded since with some syntactic sugar and more recently the introduction of sum types and exhaustiveness to go along with pattern matching.

I think there should be a second edition of this book then :)

Re: Crafting Interpreters

#66
Curious question from someone new to the programming field who lacks a formal CS background: How are books like this one are meant to be consumed? Do you read it cover to cover as you code along with the author in a way YouTube tutorials work?

The main reason for asking is, I don't know if I'm lacking in natural gifts (really likely) but I can't seem to retain knowledge like that. It feels nice to onboard myself to a language or framework by doing so, but afterwards I will still struggle to connect pieces together.

I'm interested to learn more on how language interpreters work, I just don't know if the format is something that will assist me. I'm trying to compliment and assist my brain with note taking after reading the note taking thread that is currently in the front page, so perhaps that will change.

Re: Crafting Interpreters

#67

I really wish this book used something other than Java. Nothing against Java - just that I don't know it and don't feel excited about learning it.

Don't use Java then. The Java bits are just an example, you can write it in any language you want.

Re: Crafting Interpreters

#69

Curious question from someone new to the programming field who lacks a formal CS background: How are books like this one are meant to be consumed? Do you read it cover to cover as you code along with the author in a way YouTube tutorials work? The main reason for asking is, I don't know if I'm lacking in natural gifts (really likely) but I can't seem to retain knowledge like that. It feels nice to onboard myself to a…

Im my experience following - as in actually doing the steps - works wonders.

Re: Crafting Interpreters

#70

Curious question from someone new to the programming field who lacks a formal CS background: How are books like this one are meant to be consumed? Do you read it cover to cover as you code along with the author in a way YouTube tutorials work? The main reason for asking is, I don't know if I'm lacking in natural gifts (really likely) but I can't seem to retain knowledge like that. It feels nice to onboard myself to a…

For this book, that is absolutely what you should do. It starts you off building a simple parser and interpreter, and then has you add features to both as you progress through the book. Skipping sections can mean that you end up missing functionality you might need.
Post reply on HN