

Mozilla's Narcissus meta-circular JavaScript interpreter - ldayley
https://github.com/mozilla/narcissus

======
lubutu
I'm confused. This is a self-interpreter, but in what sense is it
metacircular? It's an implementation of JavaScript in JavaScript; it does
_not_ appear to rely on the host's evaluation semantics, which is necessary to
qualify as a metacircular evaluator: <http://en.wikipedia.org/wiki/Meta-
circular_evaluator>

~~~
stralep
Parent interpreter is not host, it is JavaScript. No one said that parent and
child interpreters cannot have the same language :)

~~~
lubutu
You misunderstand: the parent interpreter is JavaScript, yes, but the child
interpreter does not rely on the parent's evaluation semantics, which means it
is _not_ a metacircular evaluator, it's just a self-interpreter. See the
Wikipedia article for more information.

~~~
stralep
It's currently 4AM here, so I cannot reason right :) If I misunderstood your
point, my deepest apologies.

------
thristian
Mozilla also has a Firefox addon called Zaphod which will allow you to force
scripts in web-pages to be executed with your (customized) Narcissus
interpreter, instead of executing scripts with SpiderMonkey directly:

<https://mozillalabs.com/zaphod/>

------
tikhonj
A cool project that uses this is DoctorJS[1][2]. It's a ctags tool optimized
for JavaScript and a JavaScript static analyzer.

[1]: <http://doctorjs.org/> [2]: <https://github.com/mozilla/doctorjs>

Unfortunately, it does not seem to create Emacs-style tags at the moment. I
had meant to add that to it--I even have some half-baked code lying around
somewhere--but never got around to finishing it :(

Still, it's a cool project anybody working with JavaScript should check out.

------
mcmire
This is interesting, but doesn't appear to be self-hosting. That is, you can't
use Narcissus to compile Narcissus, you have to use SpiderMonkey to run the
Narcissus code (that is the impression I get from reading the wiki, anyway,
someone correct me if I'm wrong). Still, it is cool that the objects that
Narcissus parses in the "user" code are stored exactly the same way in the
"host" code.

------
lalc
Funny enough, I just started using this the other day to write a little async
callback JS pre-processor. I wanted to just tokenize but then I found out that
JS's regexp literals make JS ambiguous to parse. This project turned out to be
a huge boon--really easy to patch to find particular token boundaries.

------
ldayley
It took a moment to register the significance of the name "Narcissus". I guess
JsJs (like PyPy) just doesn't roll off the tongue.

