Live data from Hacker News

Crafting Interpreters: Closures

craftinginterpreters.com

11–20 of 62 posts

Re: Crafting Interpreters: Closures

#11
post #6

The implementation described here is inspired by Lua. Even if you already know what a closure is, it might still be a worthwile read, since it probably implements them very differently from what you are thinking! Instead of always heap-allocating variables that are used by closures, it starts by stack-allocating them and only moves them to the heap if the closure outlives its parent function. In order for this to wor…

Another approach is to do the opposite - always store all local variables in the heap, and rely on scalar replacement of aggregates to put them back onto the stack where possible. This is what I do in my Ruby interpreter. That’s definitely not compatible with a single-pass though!

Very interesting! Have you written anything about your implementation? I'm always keen to learn new techniques. I don't have much back end optimization experience (yet).

Re: Crafting Interpreters: Closures

#17

Does anyone know of any similar material that helps you create a database / distributed database from scratch?

Here is a 13 part series on implementing a database: https://cstack.github.io/db_tutorial/

It misses the optimization and execution part, i.e. how joins, filtering and aggregation is executed

Re: Crafting Interpreters: Closures

#18
post #16

Small piece of ui/ux feedback. It would be awesome if you moved the next and previous buttons to a static position so I can quickly page through the book. Right now they hop up and down.

Thanks for mentioning that. I notice this too and it bugs me. I've tried a few different layouts and positions for those navigation buttons and so far haven't found anything else I like better. My thinking at the time was that most readers aren't quickly paging through chapters so it's not a key affordance.

I'll probably do some site tweaks after I finish the last chapter. In the meantime, the layout is quite responsive. If you make the window narrower, eventually you get to a single column layout with the navigation statically positioned on top.

Re: Crafting Interpreters: Closures

#19

Author here! Happy to answer questions, accept criticism, etc. :)

I've been anticipating the Garbage Collection chapter (next on the list!) for quite some time! Do you have an estimated time frame for when it will be released? Thanks for the great book!

> I've been anticipating the Garbage Collection chapter (next on the list!) for quite some time!

Me too! It's one of the chapters I've been most looking forward to writing. (This chapter on closures was another.)

> Do you have an estimated time frame for when it will be released?

Chapters take me roughly a month, but there's pretty high variance depending on what else is going on in my life. I work on it every day, but the amount of time per day varies. My hope is that it will get faster as I get closer to the finish line. It's been a long marathon, longer than I initially anticipated.

Re: Crafting Interpreters: Closures

#20
post #7
post #3

Earlier quoted context omitted.

Any more gems like this you would recommend?

“Compiler Construction” by Niklaus Wirth (2014) [pdf] https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/... Modern Compiler Implementation in Java, C and ML. https://www.cs.princeton.edu/~appel/modern/ From Nand to Tetris https://www.nand2tetris.org/

> Niklaus Wirth (2014)

The fact that he's still writing is kind of amazing. Besides him and Knuth, who from their generation of computer scientists are still active?

Post reply on HN