Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

21–30 of 62 posts

Re: Crafting Interpreters

#21
post #9

It's a great book, I bought the paper version first, but man it was too big and heavy for my liking, ended up buying a digital copy; much more practical for notes and search... although I keep getting lost somewhere in the mountain :) I also recommend munificent's other book about game programming patterns. Both are fun to read.

Sometimes I get the spine guillotined off and replaced with a ring binding. Any print shop can do it for you, and you just lose the gutter plus a little margin. Easier to work with at a desk, and you can even split into two "books" if you feel it necessary.

But that's only for books I don't want to keep, and Crafting Interpreters is definitely a keeper...

Re: Crafting Interpreters

#22
post #21
post #9

It's a great book, I bought the paper version first, but man it was too big and heavy for my liking, ended up buying a digital copy; much more practical for notes and search... although I keep getting lost somewhere in the mountain :) I also recommend munificent's other book about game programming patterns. Both are fun to read.

Sometimes I get the spine guillotined off and replaced with a ring binding. Any print shop can do it for you, and you just lose the gutter plus a little margin. Easier to work with at a desk, and you can even split into two "books" if you feel it necessary. But that's only for books I don't want to keep, and Crafting Interpreters is definitely a keeper...

Interesting idea. Thanks.

Re: Crafting Interpreters

#25

Crafting Interpreters is the one thing that LLM's can do really really well. Because it is so easy to define and test. Here are is a new LUA interpreter implemented in Python: https://github.com/rhulha/MoonPie And here is a new language: https://github.com/rhulha/EasyScript

Is MoonPie your project? Have you written up anything about your experience and process of creating it?

Re: Crafting Interpreters

#26
post #13

I stopped reading when he started using the visitor pattern

The visitor pattern is very common in programming language implementations. I've seen it in the Rust compiler, in the Java Compiler, in the Go compiler and in the Roslyn C# compiler. Also used extensively in JetBrains' IDEs.

What do you have against this pattern? Or what is a better alternative?

Re: Crafting Interpreters

#27
post #17

Earlier quoted context omitted.

The bytecode interpreter in the second half of the book doesn't use the visitor pattern.

the parser does

The parsers in crafting interpreters do not use the visitor pattern. The visitor pattern is used when you already have a tree structure or similar. The parser is what gives you such tree structure, the AST. When you have this structure, you typically use the visitor pattern to process it for semantic analysis, code generation, etc.

Re: Crafting Interpreters

#28
post #13

I stopped reading when he started using the visitor pattern

The bytecode interpreter in the second half of the book doesn't use the visitor pattern.

No, but his first "Tree-walk Interpreter" does - he builds an AST then uses the visitor pattern to interpret it.

https://craftinginterpreters.com/representing-code.html#work...

Re: Crafting Interpreters

#29
post #6

One of the best resources for learning compiler design. The web version being free is incredibly generous.

Compiler doesn't match the title of the book.

Well, most interpreters use a compiler internally, for example to compile to byte code. The book explains that as well, so I'd recommend just reading it: https://craftinginterpreters.com/a-map-of-the-territory.html...

Re: Crafting Interpreters

#30
post #19
post #13

I stopped reading when he started using the visitor pattern

What’s bad about the visitor pattern? /gen

https://grugbrain.dev/

grug very elated find big brain developer Bob Nystrom redeem the big brain tribe and write excellent book on recursive descent: Crafting Interpreters

book available online free, but grug highly recommend all interested grugs purchase book on general principle, provide much big brain advice and grug love book very much except visitor pattern (trap!)

Grug says bad.

In all seriousness, the rough argument is that it's a "big brain" way of thinking. It sounds great on paper, but is often times not the easiest machinery to have to manage when there are simpler options (e.g. just add a method).

Post reply on HN