Live data from Hacker News

Crafting Interpreters

craftinginterpreters.com

141–150 of 193 posts

Re: Crafting Interpreters

#141

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 incredibly readable. I don't care for writing Java either but reading the first part but implementing it in c# was incredibly easy (and also ensured no copy/pasting).

Re: Crafting Interpreters

#142
post #56

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

People have asked me to write something like this many times and one of the main reasons I haven't is because it's so open-ended. With Crafting Interpreters, I felt like there was a reasonably small self-contained language I could come up with that covered almost all of the concepts I wanted to teach: variable scope, functions, closures, classes and dynamic dispatch, control flow, etc. With type systems, there are a…

Personal opinion, I'd rather you build a specific thing, with perhaps brief periods where you talk about the pros and cons of the most notable options and then why you chose what you did. As you said there's a joy in a complete system, and at least to me there would be value in discussing your set of whys because that can show people less used to system design the types of considerations involved.

I will not fault you if you don't get to any such project (I remember discovering Crafting Interpreters around the time you were like... halfway through part one? and seeing how long it took you to get through the rest of the book. The care you take to both give useful technical information and make your writing clear takes a great deal of work), but I would certainly read it as I've read much of CI if it ever exists (I need to finish going through part 2, I'm up to Closures).

Re: Crafting Interpreters

#143

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.

Hi, loved your previous work on languages (Magpie, etc.). Any update on the statically typed language you were working on? Is it still in progress? The syntax for dealing with Sum types was pretty ingenious.

Thanks for both the books, cheers.

Re: Crafting Interpreters

#144
post #9

The author is one of the lead developers for Dart, which has evolved over time into a pretty nice language.

I should clarify that I've been an engineer on the Dart team for a long time, but I wasn't one of the original designers of the language. (If I had been, the language would be pretty different.) I am on the language team now, but I'm just one of the team members and not a lead. The Dart team is really fantastic. Every day I'm grateful I get to work with such a good group of people.

Thanks to you and the rest of the team for all your great work! It really is a very nice language. I've been working almost exclusively in Dart for the last 6 months and it really is a very pragmatic and productive language.

I'm looking forward to macros and more fully featured record types.

Re: Crafting Interpreters

#145
post #9

The author is one of the lead developers for Dart, which has evolved over time into a pretty nice language.

I think Dart is underappreciated. Almost the entire compiler is written in Dart. It has a VM, AOT compiler, FFI/Native, and first class Javascript interop with ability to compile to javascript. It has first class WASM support. Null sound safety. They have experimental support for macros. Pretty impressive.

I completely agree. I was lukewarm on Dart but decided to do my new app in Flutter and it's turned out to be a great experience. Kotlin and Swift may look better on paper but Dart is very productive. The tooling is really solid and the fast compile times and hot reload really help for rapid iteration. I've also had no performance issues.

Re: Crafting Interpreters

#146
post #76

This book should be the second or maybe third step of your journey into PL compilers. The first step is to write an interpreter yourself, for a simple language you create, without knowing anything about interpreters or language design. The second step is to rewrite it, and make less mistakes! :) If you don't do this, you are never going to appreciate the nuances of this topic. And you are going to skip over concepts…

For me, I just didn't know where to start, and thought that these sorts of projects were simply magic that were beyond my skills. But reading Crafting Interpreters showed me that all I needed was a little nudge in my thinking.

I don't think I would have ever attempted to write an interpreter without first reading something like CI... I never would have gotten to your step three.

Re: Crafting Interpreters

#147

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.

What other languages do you know? If you know something with similar enough syntax (C++, C#, Javascript, etc.), even if the semantics aren't the same, you should be ok getting the basic idea of the Java code in the book, especially considering how he explains things as you go.

Then just write it in whatever language you want. When I went through the first half of the book back in 2017, I wrote it in Scala. (I did know Java, too, though, so certainly I had an easier time understanding the code examples in the book.)

Re: Crafting Interpreters

#148

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.

IMO Java's pattern matching is still fairly primitive. Not even up to the level of usefulness of Scala 2.13.

Re: Crafting Interpreters

#149
post #17

Earlier quoted context omitted.

I commiserate, it can be unforgiving, and the use of C is admittedly out of vogue.

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 years.)

I still (unfortunately, IMO) write a lot of C. Back in 2004 I thought it was great fun. But now that I've worked in safer, batteries-included languages, I find C to be a huge drag. I'm so much more productive in Rust or even Java. I could never ever ever ever approach the level of rigor you bring to your C code; I just don't find doing all that stuff to be fun or interesting... to the contrary, it feels like a huge drag: if I were "required" to do all that, I just wouldn't write any code at all in C in the first place, knowing that having to do all the testing and fuzzing and static analysis stuff would burn me out.

Anyhow, I hope I don't sound like I'm being critical... quite the opposite. I just think we live in a magnificent world where people's brains can work so so so differently when it comes to the same topic.

Re: Crafting Interpreters

#150
post #147

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.

What other languages do you know? If you know something with similar enough syntax (C++, C#, Javascript, etc.), even if the semantics aren't the same, you should be ok getting the basic idea of the Java code in the book, especially considering how he explains things as you go. Then just write it in whatever language you want. When I went through the first half of the book back in 2017, I wrote it in Scala. (I did kno…

I started reading the book after reading similar suggestions in the thread.

I know JavaScript and a bit of C and I'm not having much trouble understanding the Java code.

Post reply on HN