4 ms·
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 i
by pier25 5y ago
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.
- silasb 5y agohttps://github.com/rogchap/v8go https://github.com/rogchap/v8go is a Go library which makes this easy to accomplish.
- pier25 5y agoYeah 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.
- jart 5y agoYou 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.
- tiborsaas 5y agoWhere to get qjs.com from?
- dflock 5y agoHere, I think? https://bellard.org/quickjs/binary_releases/ https://bellard.org/quickjs/binary_releases/
- tiborsaas 5y agoThose are .exe-s, I think .com is not typo
- jart 5y agoSpoiler 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/quickjs https://github.com/jart/cosmopolitan/tree/master/third_party... Here's a prebuilt binary https://justine.lol/qjs.com https://justine.lol/qjs.com
- deleted 5y ago[deleted]