News for hackers. Stuff that matters.
Re:Step-by-step JavaScript interpreter, written in JavaScript by amasad on Thursday October 09, 2014 @07:51PM (#8435577)
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

Re:Step-by-step JavaScript interpreter, written in JavaScript by hexasquid on Thursday October 09, 2014 @04:38PM (#8434915)
This is terrific. I'd love a description of what the interpreter is actually doing at each step, perhaps optionally sent to the console. This could be a wonderful tool for teaching how JavaScript works.
Re:Step-by-step JavaScript interpreter, written in JavaScript by omphalos on Friday October 10, 2014 @06:10AM (#8436993)
There are a number of JS-in-JS stepping interpreters posted in this thread, one of which I've worked on :) For people who like this sort of thing, I think tailspin [1] is a particularly interesting example, since it supports reversible execution as well. [1] https://github.com/wthimbleby/tailspin
Re:Step-by-step JavaScript interpreter, written in JavaScript by int3 on Friday October 10, 2014 @12:45AM (#8436300)
Nice! I did something similar a while back: http://int3.github.io/metajs/
Re:Step-by-step JavaScript interpreter, written in JavaScript by rubyn00bie on Thursday October 09, 2014 @05:33PM (#8435122)
I think itd be cool to see the tokenization happen as you step through it. The highlighting is a great step in helping understand the process.
Re:Step-by-step JavaScript interpreter, written in JavaScript by yonran on Thursday October 09, 2014 @07:14PM (#8435479)
We finally have a substitute for eval within Chrome extensions! Also could be useful for experiments e.g. simulating synchronous APIs.
Re:Step-by-step JavaScript interpreter, written in JavaScript by foogered on Thursday October 09, 2014 @05:27PM (#8435100)
Cool project, but the title initially lead me to believe this was a tutorial on building a JavaScript interpreter. :(
Re:Step-by-step JavaScript interpreter, written in JavaScript by rubyn00bie on Thursday October 09, 2014 @05:34PM (#8435127)
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 by peetle on Thursday October 09, 2014 @05:33PM (#8435124)
Wait a minute, how does this interpreter allow multi-threaded execution without web workers?
Re:Step-by-step JavaScript interpreter, written in JavaScript by jaz303 on Thursday October 09, 2014 @06:51PM (#8435419)
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 by icebraining on Thursday October 09, 2014 @05:54PM (#8435215)
Thread switching? Multi-threaded just means it allows concurrent threads; they're not necessarily parallel: https://talks.golang.org/2012/waza.slide