Live data from Hacker News

Show HN: Crafting Interpreters – A handbook for making programming languages

craftinginterpreters.com

31–40 of 77 posts

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#31
post #6

Another great-looking book on making dynamic languages. There's been some good ones recently, and this one looks like another good one covering how to make a basic, interpreted language. Some of us have written 1 or 2 dynamic, interpreted languages, feel pretty comfortable with those concepts, and are interested in transiting to more advanced, static type systems and writing a good type checker. Anyone up for writing…

Writing a type-checker is fun and pretty interesting. For that, I recommend you get acquainted with formal semantics and judgements (that's just the language for describing type-systems). You'll probably be interested in then looking up * simply typed lambda calculus * Hindley-Milner type inference * bidirectional typing After that, there are all sorts of cool things like linear/affine types, system F, dependent type…

Shameless plug: If you know OCaml, then I wrote this tiny implementation of Hindley-Milner[0] for a tiny functional language.

It's (hopefully) very well commented, so it should clarify a bunch of concepts for newcomers.

[0] - https://github.com/prakhar1989/type-inference

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#32
post #6

Another great-looking book on making dynamic languages. There's been some good ones recently, and this one looks like another good one covering how to make a basic, interpreted language. Some of us have written 1 or 2 dynamic, interpreted languages, feel pretty comfortable with those concepts, and are interested in transiting to more advanced, static type systems and writing a good type checker. Anyone up for writing…

I want this too, but is weird to me that is a huge chasm in this area, where a lot of material stop at the most basic, and then it cover a niche that is complicated (like for example, type inference).

If I wanna to implement a dialect of ML, I haven't' find a simple explanation in how implement product/sum types, modules & pattern matching.

Yet, tons of type inference and other less common things.

ie: The basics stop fast and suddenly jump into something else.

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#33
post #6

Another great-looking book on making dynamic languages. There's been some good ones recently, and this one looks like another good one covering how to make a basic, interpreted language. Some of us have written 1 or 2 dynamic, interpreted languages, feel pretty comfortable with those concepts, and are interested in transiting to more advanced, static type systems and writing a good type checker. Anyone up for writing…

> more advanced, static type systems Are static type systems more advanced than dynamic type systems? This sounds surprising, given how much more one can do with a dynamic type system.

Well, you could look at a dynamic type system as just a static type system with 1 type—a sum type of everything. Looking at it that way, a dynamic type system is much less powerful.

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#34
One question here for the more advanced compiler writers.. How do you go about writing a "pre-lexer" for LISP like language where you want to expand sexpr? I.e. Does the lexer even see `(...), or does it get pre-extracted to (quote ..)? And if so, how does the pre-extraction work exactly? Is it built using regex..? That can be tricky.

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#35
post #34

One question here for the more advanced compiler writers.. How do you go about writing a "pre-lexer" for LISP like language where you want to expand sexpr? I.e. Does the lexer even see `(...), or does it get pre-extracted to (quote ..)? And if so, how does the pre-extraction work exactly? Is it built using regex..? That can be tricky.

Those are handled by the reader. If you Google "Lisp reader" and "Lisp reader macro", you should find a bunch of info.

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#36
post #10

Earlier quoted context omitted.

> Pierce's Types and Programming Languages Pierce's book is as approachable as you're likely to see with respect to type systems. You mostly just have to dig in.

Yeah, I suspect you're correct at the moment. In fact, TaPL looks pretty approachable for an academic book. But it seems to be there's a place for a more popular book on type systems and making a statically-typed language, in the vein of this Crafting Interpreters book (and others like it). Perhaps I'll read TaPL, write a nice statically-typed language, and then write the book I'm looking for.

I'm reading TaPL, done 4 chapters.

I think you can replace the math with intuitive diagrams and be a little less rigorous and that would be a book for the masses.

TaPL requires you to learn a lot between coding sessions too which may put off more practically minded folk.

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#37
post #34

One question here for the more advanced compiler writers.. How do you go about writing a "pre-lexer" for LISP like language where you want to expand sexpr? I.e. Does the lexer even see `(...), or does it get pre-extracted to (quote ..)? And if so, how does the pre-extraction work exactly? Is it built using regex..? That can be tricky.

Lisp dialects usually have an input mechanism called a "reader". It scans the character syntax and produces the equivalent object, combining lexical analysis and parsing. Special notations like 'x denoting the same thing (quote x) are easily handled here. When the reader sees a quote, it consumes it, calls itself recursively to scan the expression which follows to get an object O and then returns the object (quote O).

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#38
post #5

Thank you so much for the book, please, continue! I am currently working on Scheme R5RS implementation in Java. It is a hobby project, but I'm really enjoying it. It is somewhat enlightening. Look forward to reading the Optimization chapter: I couldn't find much useful and practical info on that. I think it is quite easy to implement your interpreter, but it is really difficult (at least for me) to make it fast. Can…

Lisp In Small Pieces by Christian Queinnec

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#39
post #14

Earlier quoted context omitted.

For making an efficient Scheme implementation: most everything written by R. Kent Dybvig or his students. I'd start with his PHd thesis (Three Implementation Models for Scheme, specifically the stack-based part). http://www.cs.indiana.edu/~dyb/ (See also Lua's upvalues for a way to optimize closure variable access that's a bit simpler than his display closures).

> See also Lua's upvalues for a way to optimize closure variable access Yes! In fact, that's how the C version of the interpreter in my book implements closures. It's pretty brilliant. <3 those Lua folks.

Will you cover anything about LuaJIT's "NaN-coding"?

Or perhaps do you have a link about how it works?

Re: Show HN: Crafting Interpreters – A handbook for making programming languages

#40
post #6

Another great-looking book on making dynamic languages. There's been some good ones recently, and this one looks like another good one covering how to make a basic, interpreted language. Some of us have written 1 or 2 dynamic, interpreted languages, feel pretty comfortable with those concepts, and are interested in transiting to more advanced, static type systems and writing a good type checker. Anyone up for writing…

I'm starting a series of blog posts on making first a dynamic Lisp and then adding a type system to it, then type inferencer, etc. I'd be interested in what resources you found helpful and easy to read.

Are you going to share the links once you're done?
Post reply on HN