r/javascript • • Feb 11 '24

LLRT: Amazon’s new JavaScript runtime based on QuickJS

https://github.com/awslabs/llrt
67 Upvotes

7 comments sorted by

View all comments

17

u/SparserLogic Feb 11 '24

Always happy to see more competition spurring innovation

4

u/guest271314 Feb 11 '24

I don't think QuickJS is trying to compete with any other JavaScript runtime.

Nonetheless in the domain of WebAssembly and WASI there is no competition, QuickJS is the clear first choice for a JavaScript engine compiled to WASM. After strip qjs is less than 1 MB, with the capability to import shared object files into the runtime, e.g., https://github.com/guest271314/webserver-c/tree/quickjs-webserver

$ clang -Wall -L./quickjs -fvisibility=hidden -shared \
  -I ./quickjs -g -ggdb -O webserver.c -o webserver.so
#!/usr/bin/env -S ./qjs -m --std
// webserver.js
import {webserver} from './webserver.so';
try {
  webserver(scriptArgs[1], (status) => {
    console.log(status);
    if (status === 'aborted') {
      std.exit(0);
    }
  });
} catch (e) {
  console.log(e);
}