Live data from Hacker News

Step-by-step JavaScript interpreter, written in JavaScript

neil.fraser.name

1–10 of 12 posts

Re: Step-by-step JavaScript interpreter, written in JavaScript

#6
post #3

Cool project, but the title initially lead me to believe this was a tutorial on building a JavaScript interpreter. :(

There's on in the project on github that looks like it's originally from Google. You can probably find docs specifically on it (and it looks like the source is well documented).

Re: Step-by-step JavaScript interpreter, written in JavaScript

#7
post #5

Wait a minute, how does this interpreter allow multi-threaded execution without web workers?

Thread switching? Multi-threaded just means it allows concurrent threads; they're not necessarily parallel: https://talks.golang.org/2012/waza.slide

Re: Step-by-step JavaScript interpreter, written in JavaScript

#8
post #5

Wait a minute, how does this interpreter allow multi-threaded execution without web workers?

It uses a small-step interpreter [1]. Rather than capturing the interpreter's state on the native call stack, small-step interpreters explicitly model said state using stacks of objects - one per active AST node - and environments. Because they're no longer bound to the stack of the implementation language, execution may be cycled, paused and resumed at will.

[1] http://matt.might.net/articles/writing-an-interpreter-substi...

Re: Step-by-step JavaScript interpreter, written in JavaScript

#10
This is great. I also implemented a JS stepping interpreter in JS [1] but using a different approach. I let the host JS environment do parsing and evaluation. I just use generators to pause executions and then pass the code through a ES6 generator transpiler[2]. See the demo[3].

[1] http://amasad.me/2014/01/06/building-an-in-browser-javascrip... [2] https://github.com/facebook/regenerator [3] http://debugjs.com/#example

Post reply on HN