4 ms·
Js.js - A JavaScript interpreter in JavaScript
- Animus7 15y ago> 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.
- lukeholder 15y agoso eval() written in js?
- jterrace 15y agoNot quite. It will support everything that SpiderMonkey's API supports when embedding the interpreter into a C++ application. Much more powerful than eval().
- cjfont 15y agoAny thoughts as to applications for this? At ~65MB, I don't see this getting used client side.
- Animus7 15y agoI 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.
- wahnfrieden 15y agoThere's also going to be an enormous startup time as it has to parse and compile all that code, even if it's already cached.
- spullara 15y agoActually, 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.
- jterrace 15y ago65MB is our current unoptimized, uncompressed version. I expect the final version to be around 5-10MB. Still large, but not quite as bad.
- jakejake 15y agoi can see some possible for this where you could add support to your application for plugin development or even macro-type scripting within a sandbox.
- rpearl 15y agoThis appears to be the same goal as https://github.com/mozilla/narcissus/ https://github.com/mozilla/narcissus/ but substantially less clever.
- deleted 15y ago[deleted]
- MatthewPhillips 15y agoIsn't Narcissus primarily for developing Harmony features?
- gkoberger 15y agoOther 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.
- rpearl 15y agoerr... what's the goal of the featured link, js.js? It's even worse--all of Spidermonkey compiled to llvm and then to javascript.
- cdcarter 15y agoThe best part is that the blob is too big to explore on github.
- aarondf 15y agoI believe this is how Cobb and Saito slipped into Limbo.
- deleted 15y ago[deleted]
- _Y_ 15y agoOr how another cheap "Yo dawg" joke started.
- zacharytamas 15y agoThese kinds of things always make me think of PyPy and its snake-eating-itself (ouroboros) logo.
- AshleysBrain 15y agoPage seems to be missing a "why?" section. Seriously, why? What does it do that eval() doesn't?
- stan_rogers 15y agoIt'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.
- charliesome 15y agoIt'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?
- jterrace 15y agoAgreed, 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.
- gootik 15y agoA very good example of Atwood's Law: any application that can be written in JavaScript, will eventually be written in JavaScript.
- LeafStorm 15y agoSomehow I don't think this really counts as "written in JavaScript."
- joshfraser 15y agoThere 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.