Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One great feature of QJS is it can create C executables or modules from JS.

AFAIK the JS code is not converted to C, but the compiler produces bytecode which is bundled with C code.

This is interesting because it means it's possible to execute JS code from languages that have C interop. So for example you can do SSR rendering of Svelte components in a Go server application. At least in theory, I've never tried this.



You can use QuickJS as an Actually Portable Executable.

    $ echo 'console.log("hello world\n");' >hello.js
    $ zip o//third_party/quickjs/qjs.com hello.js
      adding: hello.js (stored 0%)
    $ o//third_party/quickjs/qjs.com /zip/hello.js
    hello world
Just add your source code to the qjs.com executable using InfoZIP and you've got a single file releasable binary that'll run on seven operating systems. It's also about 700kb in size.


Where to get qjs.com from?


Spoiler alert

    git clone https://github.com/jart/cosmopolitan
    cd cosmopolitan
    make -j8 o//third_party/quickjs/qjs.com
Build it on Linux but it runs anywhere. https://github.com/jart/cosmopolitan/tree/master/third_party... Here's a prebuilt binary https://justine.lol/qjs.com



Those are .exe-s, I think .com is not typo


https://github.com/rogchap/v8go is a Go library which makes this easy to accomplish.


Yeah but how much memory does that consume?

QJS is a lot smaller than V8. Granted, it doesn't have JIT, but for certain stuff it's ok.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: