Live data from Hacker News

QuickJS JavaScript Engine

bellard.org

11–20 of 279 posts

Re: QuickJS JavaScript Engine

#17
post #15

Would it be possible to compile a nodejs app to a binary with this? If so, would performance be any better?

I think you'd need to translate node specific APIs in order to make this work, e.g. i/o features and require function. It is probably more work than just rewriting the app to use QuickJS APIs instead, but I don't think it's impossible to make some sort of compatibility or translation layer. Couldn't say if it'd be more performant, but it'd have a killer feature over node: compilation to single binary without dependencies.

Re: QuickJS JavaScript Engine

#18

Earlier quoted context omitted.

This is fast enough, it could be used to write command line utilities in Javascript! What about a Javascript OS in the style of the Lisp machines or early Smalltalks?

Record-query [1] embeds v8 for its query language, which seems to add a significant amount of heft. I know that couchdb uses js for querying as well. It seems like this could be another option for something like that. [1] https://github.com/dflemstr/rq

Convert the QuickJS code into Rust using c2rust[1], then reuse in rq.

[1] https://github.com/immunant/c2rust

Re: QuickJS JavaScript Engine

#19
post #15

Would it be possible to compile a nodejs app to a binary with this? If so, would performance be any better?

Doesn't look like. It uses the `os` module name for its own thing, so you'd need at a minimum to patch that (in addition to actually having to implement all of Node's APIs on top of the `std` primitives or as C modules)

Re: QuickJS JavaScript Engine

#20
I just tried building this on my Mac and it looked initially like it all was building fine, but it eventually failed when building qjs32.

Thinking this probably didn't matter much I went ahead and ran `./qjs examples/hello.js` which worked as advertised – cool! Tried `./qjsbn examples/pi.js 5` and it worked as well – very cool! Then I tried `./qjs examples/hello_module.js` and got this:

    SyntaxError: unsupported keyword: import
        at examples/hello_module.js:3
I don't know what I did wrong – anyone else try it yet?
Post reply on HN