Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

151–160 of 193 posts

Re: Crafting Interpreters

#151

Earlier quoted context omitted.

>really helped me internalize the concepts, and they are useful all over the place, not just in compilers. Which are some of those places? Parsing data formats could be one, I guess.

IMO compilers make you a lot more mature in recursive algorithms and trees, and then after that much more conscious about what exactly the code you write resolves to in terms of that languages semantics. Learning how closures work(variable capture and having to traverse the scope stack to find bound variables) is also a positive.

Makes sense, thanks.

Re: Crafting Interpreters

#152

Earlier quoted context omitted.

As the author of a POSIX standard utility, I would advise you to only reach for such utilities when portability is the most important thing. POSIX utilities are not great. Lex and Yacc included.

Are POSIX utilities even portable? They tend to have poor windows support. And they also tend to target C, which has a high ceiling for portability, but also a high bar for making things portable (whereas more modern languages are often just portable by default). My take on POSIX utilities would be only to use them on Linux platforms where they effectively form a "native" part of the platform.

> They tend to have poor windows support

Does Windows claim POSIX compatibility these days? I didn't think so? I remember NT's old POSIX subsystem, but is that even a thing anymore?

> My take on POSIX utilities would be only to use them on Linux platforms

I mean, only use them on POSIX-compliant systems. Linux is just one of them.

At the risk of sounding childishly derisive, when someone is talking about "portability", I think they're generally not bothering to include Windows in the mix, as Windows doesn't really share all that much of a common denominator with much else.

Re: Crafting Interpreters

#153

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.

Lots of people have done implementations in other languages: https://github.com/munificent/craftinginterpreters/wiki/Lox-... I did the first half in Clojure (in order to teach myself Clojure), worked just fine. I had to do a bit of translation but it's really not a lot.

I find it’s the best way to work through these types of books - otherwise I tend to just copy the code mindlessly. Doing the exercises from a book in another language forces you to consume the semantics of it better.

I did the Torsten Ball books in Kotlin rather than Go and learned a lot

Re: Crafting Interpreters

#154

Earlier quoted context omitted.

Do you have any thoughts about how to read some of the next step books like Engineering a Compiler/Dragon Book? I don't normally read large technical books end to end so I'm curious how others approach it. I am going through Crafting Interpreters right now and I like how it has well defined checkpoints that help me know that I can move on when I understand the current material. I skimmed Engineering a Compiler and it…

I think everyone has to pick a strategy for consuming material that works best for their brain. For me, when I read textbooks, I tend to read them front to back. Only a fraction of it sticks on the first read through, but I accept that. I've tried to go really slow and do all of the exercises to make it all stick, but I usually just run out of steam and give up. I'd rather just get through the whole thing. Then, in t…

Thanks for the perspective, I sometimes have completionist tendencies so it's hard to skim without feeling I'm missing parts, but also it can certainly lead to motivation running out at times. And thanks for Crafting Interpreters, I am really enjoying it so far!

Re: Crafting Interpreters

#155
post #19

I know this book has been praised before on HN, but I've been personally a bit disappointed. It's suitable for someone with no very little knowledge on the topic, but it doesn't really cover any advanced topic.

I trust that you're correct, but I'm glad that this is the case. There are books designed to be introductory, and there are books that serve as reference for advanced topics and state-of-the-art techniques. The first type can often serve as an enabler for the second type.

I’m personally very excited for this book. When I would get programming books at the library as a youth, it would be a gamble as to “introductory or advanced?” and I needed the former way more. “3D Rendering in X Windows” wasn’t great at for me at 13, and getting into topics like this takes a solid foundation.

Re: Crafting Interpreters

#156
codecrafters (YC S22, http://codecrafters.io) has a new module called "Building Your Own Interpreter" that works its way through this book. It's great because you work in small chunks, each of which has unit tests to tell you if you got, e.g. scanning string literals correct.

Currently free while the module is in beta. I spent today working through all of the lexer exercises in Rust (I'm currently learning it), and had a lot of fun.

Re: Crafting Interpreters

#157
post #149

Earlier quoted context omitted.

Oh, I love C. [1] But yes, unforgiving. And a lot of magic, with special variables, macros, and functions that you must know. And unclear scoping. [1]: https://gavinhoward.com/2023/02/why-i-use-c-when-i-believe-i...

OT, but: I remember reading that post of yours a year or so ago! It was so bizarre to me, but also really fun. I feel like you are among what is probably a very small group of people who could write something security-sensitive in C, and I would feel comfortable using it. (I am still less than thrilled that I have to rely on OpenSSL, regardless of the process improvements its developer team has made in more recent ye…

No offense taken; I know my brain is different. :)

> I feel like you are among what is probably a very small group of people who could write something security-sensitive in C, and I would feel comfortable using it.

This is probably the most complimentary thing anyone has ever said to me. Thank you! I hope I can live up to that.

Re: Crafting Interpreters

#158

Author here. Seeing all of the positive comments about my book is really warming my heart. I appreciate everyone and I'm glad so many people have enjoyed the book. I put a ton of time and love into it and it's gratifying to see it had the effect I'd hoped for.

Your book is legendary and I have recommended it to a good number of students/programmers-in-learning. Haven't ever made it through (no matter how good the textbook, I'm still not a textbook person...) but immense respect for the time and dedication required to make such a brilliant and engaging learning material.

Re: Crafting Interpreters

#159

Earlier quoted context omitted.

IMO compilers make you a lot more mature in recursive algorithms and trees, and then after that much more conscious about what exactly the code you write resolves to in terms of that languages semantics. Learning how closures work(variable capture and having to traverse the scope stack to find bound variables) is also a positive.

Makes sense, thanks.

And that’s just for your first recursive descent compiler. One thing to remember is that you will also one day want extended functionality in your language and either implement C FFI in your language(straightforward or even freely done for you depending on language) and call some C library for the purpose or you have to implement the functionality somehow. So you end up writing a lot of stuff you wouldn’t otherwise.

Re: Crafting Interpreters

#160

Author here. Seeing all of the positive comments about my book is really warming my heart. I appreciate everyone and I'm glad so many people have enjoyed the book. I put a ton of time and love into it and it's gratifying to see it had the effect I'd hoped for.

Thank you for game programming patterns as well.
Post reply on HN