Hello there. I've been hacking away at a small JavaScript runtime I'm working on, which I call sev. It runs on top of the Bali JavaScript engine, which is also written in Nim.
It isn't very useful right now (it's just 54 lines of code because Bali is really good at abstracting away the complexity!), but it has a file reading function (IO.readFile) and a HTTP-get function (HTTP.get) which just uses curly.
Here's a sample program. .. code-block:: java
let x = IO.readFile("test.js") // Read our own code console.log(x)
var resp = HTTP.get("https://example.com") console.log(resp.body) console.log(resp.code) console.log(resp.url) console.log(new Date()) // This is from the Bali standard library implementation, based off of ECMA262. It's roughly equivalent to what you'd see in a browser :^)
I'm really happy with this, because it shows that my JavaScript interpreter is slowly maturing and is stable enough to be embedded into another program. It recently switched to Boehm GC, which made it a lot less crash-prone.
Here's the source code (just 54 lines of Nim), if anyone's interested: https://github.com/xTrayambak/sev
Here's the source code to the Bali engine, which contains the bytecode emitter+VM+Ecmascript functions (in ~10K lines of code): https://github.com/ferus-web/bali
It recently switched to Boehm GC, which made it a lot less crash-prone.
For development that is a fine choice but for production it might be unusuable. You could write JS code crafting integers that look like pointers confusing Boehm so that it must die with OOM, for example.
In fact, here is my advice: Get your GC tech right asap. Else your entire foundation is on shaky ground and later on it'll be so much more expensive to fix.