It's probably cheating a little to just grab an existing Javascript interpreter written in C++, compile that with emscripten and call it a Javascript interpreter in Javascript. When you compile C++ code, do you say that the program is in Assembly?
Agreed, it's partially cheating, although a lot of work went into getting it to compile to LLVM and patching it work with Emscripten. That's not where it stops though. The plan is to make the library work just like the SpiderMonkey JS API, which will require wrapper scripts in JS.
Other than prototyping new JS features (or to say you did it), what's the use? It will never come close to being fast enough to be a viable alternative, like PyPy is.
I don't even think the worst part is the download (which can be cached). The worst part is the fact that you're running your script, interpreted by a weirdly generated unoptimized script, interpreted by a scripting engine which only then runs on metal. I'm shooting in the dark, but I'd bet the performance and memory usage would be a disaster for anything but Hello, world.
Actually, right now, even Hello world is a disaster. My guess is that this will drive some interesting improvements to emscripten and LLVM so there may be some benefits down the line.
I'm not super familiar with Narcissus in practice, but on paper your projects sound very similar. Were there any interesting reasons why you opted to make this project instead?
There are plenty of things I've done in my life that didn't make a lot of sense, but I did them just because I could. I'll happily put js.js in the same bucket and give props for creativity over usefulness.
It's similar to the metacircular Scheme interpreter in Scheme in SICP. It's not that interpreting JavaScript in JavaScript (especially if that JavaScript is running on a full-blown and more efficient interpreter itself) is a practical end, but that it demonstrates a concept: language as data and data as language. As an implementation, it is merely interesting -- but imagine writing code in a language closer to the problem domain you're working with that just happens to run on JavaScript.
Not quite. It will support everything that SpiderMonkey's API supports when embedding the interpreter into a C++ application. Much more powerful than eval().
> Instead of trying to create an interpreter from scratch, SpiderMonkey is compiled into LLVM and then emscripten translates the output into JavaScript.
Heh, this is pretty much the epitome of hacking: needlessly complicated, ultimately pointless, but still awesome, clever and inspiring.