quickjs-emscripten VS jco

Compare quickjs-emscripten vs jco and see what are their differences.

quickjs-emscripten

Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions (by justjake)

jco

JavaScript tooling for working with WebAssembly Components (by bytecodealliance)
SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
surveyjs.io
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
quickjs-emscripten jco
21 9
1,130 518
- 7.1%
9.4 9.4
20 days ago 3 days ago
TypeScript Rust
GNU General Public License v3.0 or later Apache License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

quickjs-emscripten

Posts with mentions or reviews of quickjs-emscripten. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-12-09.
  • New QuickJS Release
    6 projects | news.ycombinator.com | 9 Dec 2023
    Based on your comment below I think you figured out the difference - but if you're looking to execute JS, you can pick between ShadowRealm (where available, or using a polyfill) or my library quickjs-emscripten.

    Pros of quickjs-emscripten over ShadowRealm:

    - You can use quickjs today in any browser with WASM. ShadowRealm isn't available yet, and polyfills have had security issues in the past. See https://www.figma.com/blog/an-update-on-plugin-security/

    - In ShadowRealm eval, untrusted code can consume arbitrary CPU cycles. With QuickJS, you can control the CPU time used during an `eval` using an [interrupt handler] that's called periodically during the eval.

    - In ShadowRealm eval, untrusted code can allocate arbitrary amounts of memory. With QuickJS, you can control both the [stack size] and the [heap size] available inside the runtime.

    - quickjs-emscripten can do interesting things with custom module loaders and facades that allow synchronous code inside the runtime to call async code on the host.

    Pros of ShadowRealm over QuickJS:

    - ShadowRealm will (presumably?) execute code using your native runtime, probably v8, JavaScriptCore, or SpiderMonkey. Quickjs is orders of magnitude slower than JIT'd javascript performance of v8 etc. It's also slower than v8/JSC's interpreters, although not by a huge amount. See [benchmarks] from 2019.

    - You can easily call and pass values to ShadowRealm imported functions. Talking to quickjs-emscripten guest code requires a lot of fiddly and manual object building.

    - Overall the quickjs(-emscripten) API is verbose, and requires manual memory management of references to values inside the quickjs runtime.

    [interrupt handler]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [stack size]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [heap size]: https://github.com/justjake/quickjs-emscripten/blob/main/doc...

    [benchmarks]: https://bellard.org/quickjs/bench.html

  • Extism Makes WebAssembly Easy
    13 projects | news.ycombinator.com | 4 Oct 2023
    The thing I want to achieve with WebAssembly is still proving a lot harder than I had anticipated.

    I want to be able to take strings of untrusted code provided by users and execute them in a safe sandbox.

    I have all sorts of things I want this for - think custom templates for a web application, custom workflow automation scripts (Zapier-style), running transformations against JSON data.

    When you're dealing with untrusted code you need a really robust sandbox. WebAssembly really should be that sandbox.

    I'd like to support Python, JavaScript and maybe other languages too. I want to take a user-provided string of code in one of those languages and execute that in a sandbox with a strict limit on both memory usage and time taken (so I can't be crashed by a "while True" loop). If memory or time limit are exceeded, I want to get an exception which I can catch and return an error message to the user.

    I've been exploring options for this for quite a while now. The furthest I've got was running Pyodide inside of Deno: https://til.simonwillison.net/deno/pyodide-sandbox

    Surprisingly I've not found a good pattern for running a JavaScript interpreter in a WASM sandbox yet. https://github.com/justjake/quickjs-emscripten looks promising but I've not found the right recipe to call it from server-side Python or Deno yet.

    Can Extism help with this? I'm confident I'm not the only person who's looking for a solution here!

  • Node on Web. Use Nodejs freely in your browser with Linux infrastructure.
    8 projects | /r/node | 3 Jul 2023
    "Safely execute untrusted Javascript in your Javascript, and execute synchronous code that uses async functions" quickjs-emscripten, NPM
  • Sandboxing JavaScript Code
    2 projects | news.ycombinator.com | 19 Apr 2023
    This maybe, as a start?

    https://github.com/justjake/quickjs-emscripten

  • Hacker News top posts: Nov 20, 2022
    5 projects | /r/hackerdigest | 20 Nov 2022
    QuickJS Running in WebAssembly\ (17 comments)
  • QuickJS Running in WebAssembly
    1 project | /r/hypeurls | 19 Nov 2022
    4 projects | news.ycombinator.com | 19 Nov 2022
    The library was inspired by Figma’s blog posts about their plug-in system: https://github.com/justjake/quickjs-emscripten#background
  • Show HN: Run unsafe user generated JavaScript in the browser
    14 projects | news.ycombinator.com | 19 Nov 2022
    If you need to call into user-generated Javascript synchronously or have greater control over the sandbox environment, you can use WebAssembly to run a Javascript interpreter: https://github.com/justjake/quickjs-emscripten#quickjs-emscr...

    QuickJS in WebAssembly is much slower than your browser's native Javascript runtime, but possibly faster than async calls using postMessage. As an added bonus, it can make async functions in the host appear to be synchronous inside the sandbox using asyncify: https://emscripten.org/docs/porting/asyncify.html.

  • Why Would Anyone Need JavaScript Generator Functions?
    19 projects | news.ycombinator.com | 7 Nov 2022
    You can use One Weird Trick with generator functions to make your code "generic" over synchronicity. I use this technique to avoid needing to implement both sync and async versions of some functions in my quickjs-emscripten library.

    The great part about this technique as a library author is that unlike choosing to use a Promise return type, this technique is invisible in my public API. I can write a function like `export function coolAlgorithm(getData: (request: I) => O | Promise): R | Promise`, and we get automatic performance improvement if the user's function happens to return synchronously, without mystery generator stuff showing up in the function signature.

    Helper to make a function that can be either sync or async: https://github.com/justjake/quickjs-emscripten/blob/ff211447...

    Uses: https://cs.github.com/justjake/quickjs-emscripten?q=yield*+l...

  • Why Am I Excited About WebAssembly?
    9 projects | news.ycombinator.com | 17 Jul 2022
    This seems like a pretty nice, recently enabled way of getting a sandboxed js environment: QuickJS compiled to WASM: https://github.com/justjake/quickjs-emscripten.

jco

Posts with mentions or reviews of jco. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-01-26.
  • WASI 0.2.0 and Why It Matters
    8 projects | news.ycombinator.com | 26 Jan 2024
    > WASI-Preview2's benefits are not going to be realized in a browser, it's more for the non-web world

    The jco project (https://github.com/BytecodeAlliance/jco) provides an implementation of the Component Model and WASI Preview 2 for JavaScript systems. Right now, node.js support is complete, but support for Web embeddings is in progress and coming soon.

    > These interpreted languages can run in WASM, but only as language interpreter inside the WASM interpreter - so they work, but they are not efficient.

    The Bytecode Alliance has made big improvements to SpiderMonkey performance on WASM/WASI systems, and has work in progress to take advantage of SpiderMonkey's "native" codegen targeting WASM: https://cfallin.org/blog/2023/10/11/spidermonkey-pbl/. We targeted JS first for this work because it is the most popular language with our customers and users, but we expect that this will show the path to adding similar improvements to Ruby, Python, and other languages commonly thought of as "interpreted".

  • The New Wasmer JavaScript SDK
    2 projects | news.ycombinator.com | 21 Dec 2023
    I use @wasmer/wasi for my npm package `trealla` (wasm port of a Prolog interpreter). For the most part I'm pretty happy with it, but the file size is quite large[1] (taking up around half my bundle size), and it looks like @wasmer/sdk is even larger (wasmer.sh downloads a 1.7MB gzipped wasm binary that I assume is the runtime). It's a tough sell to the frontend folks when my package is this big... currently I have my eye on jco[2] which I hope will be much lighter.

    [1]: https://bundlephobia.com/package/@wasmer/[email protected]

    [2]: https://github.com/bytecodealliance/jco

  • Lightweight, portable and secure Wasm runtimes and their use cases.
    2 projects | dev.to | 15 Dec 2023
    You literally write the code in the language you prefer, and given the toolchain is in place -and it's in (experimental or preview) place for JavaScript, with teams working on it, like for example JCO- you can compile with Wasm as target.
  • Prettier $20k Bounty was Claimed
    16 projects | news.ycombinator.com | 27 Nov 2023
    The roadmap I linked above. The WASI folks have done a poor job at communicating, no doubt, but I'm surprised someone like yourself literally building a competitor spec isn't following what they are doing closely.

    Just for you I did some googling: see here[0] for the current status of WASI threads overall, or here[1] and here[2] for what they are up to with WASI in general. In this PR[3] you can see they enabled threads (atomic instructions and shared memory, not thread creation) by default in wasmtime. And in this[4] repository you can see they are actively developing the thread creation API and have it as their #1 priority.

    If folks want to use WASIX as a quick and dirty hack to compile existing programs, then by all means, have at it! I can see that being a technical win. Just know that your WASIX program isn't going to run natively in wasmtime (arguably the best WASM runtime today), nor will it run in browsers, because they're not going to expose WASIX - they're going to go with the standards instead. so far you're the only person I've met that thinks exposing POSIX fork() to WASM is a good idea, seemingly because it just lets you build existing apps 'without modification'.

    Comical you accuse me of being polarizing, while pushing for your world with two competing WASI standards, two competing thread creation APIs, and a split WASM ecosystem overall.

    [0] https://github.com/bytecodealliance/jco/issues/247#issuecomm...

    [1] https://bytecodealliance.org/articles/wasmtime-and-cranelift...

    [2] https://bytecodealliance.org/articles/webassembly-the-update...

    [3] https://github.com/bytecodealliance/wasmtime/pull/7285

    [4] https://github.com/WebAssembly/shared-everything-threads

  • WASM by Example
    16 projects | news.ycombinator.com | 15 Nov 2023
    The component model is already shipping in Wasmtime, and will be stable for use in Node.js and in browsers via jco (https://github.com/bytecodealliance/jco) soon. WASI Preview 2 will be done in December or January, giving component model users a stable set of interfaces to use for scheduling, streams, and higher level functionality like stdio, filesystem, sockets, and http on an opt-in basis. You should look at wit-bindgen (https://github.com/bytecodealliance/wit-bindgen) to see some of the languages currently supported, and more that will be mature enough to use very soon (https://github.com/bytecodealliance/componentize-py)

    Right now jco will automatically generate the JS glue code which implements a Component Model runtime on top of the JS engine's existing WebAssembly implementation. So, yes, Components are a composition of Wasm Modules and JS code is handling passing values from one module/instance to another. You still get the performance benefits of running computation in Wasm.

    One day further down the standardization road, we would like to see Web engines ship a native implementation of the Component Model, which might be able to make certain optimizations that the JS implementation cannot. Until then you can consider jco a polyfill for a native implementation, and it still gives you the power to compose isolated programs written in many languages and run them in many different contexts, including the Web.

    (Disclosure: I am co-chair of WASI, Wasmtime maintainer, implemented many parts of WASI/CM)

  • Spin 2.0 – open-source tool for building and running WASM apps
    13 projects | news.ycombinator.com | 4 Nov 2023
    (As a side note for the JS support — adapting QuickJS has been extremely helpful in getting JS support out; however, we are in the process of rebuilding the JS runtime using SpiderMonkey (with which a few people on the team have significant experience) and JCO (https://github.com/bytecodealliance/jco), and the web platform compatibility makes it a significantly better proposition for things like 3rd party dependencies).

    C# is an interesting one — the .NET team at Microsoft (and in particular Steve Sanderson from that team) has been making tremendous progress in ahead-of-time compilation for .NET and generating Wasm and WASI compatible binaries (as opposed to their initial approach on Blazor), and experimenting with that led us to build support for Spin as well.

    Finally, we do a lot to support other popular languages and their Wasm support — two examples: Python (https://github.com/bytecodealliance/componentize-py) and Java / TeaVM (https://github.com/fermyon/teavm-wasi), for which we haven't fully integrated Spin support, but we hope to get there soon.

    I hope this explains a bit our process on language support, happy to expand on any point here.

  • Extism Makes WebAssembly Easy
    13 projects | news.ycombinator.com | 4 Oct 2023
    That's really useful. This page in particular: https://github.com/bytecodealliance/jco/blob/main/EXAMPLE.md

    Being able to run "jco wit cowsay.wasm" to see what interfaces that .wasm file provides solves a problem I've run into a bunch of times in the past.

  • Sandboxing JavaScript Code
    2 projects | news.ycombinator.com | 19 Apr 2023

What are some alternatives?

When comparing quickjs-emscripten and jco you can also consider the following projects:

wasmtime - A fast and secure runtime for WebAssembly

componentize-py

wasmer - 🚀 The leading Wasm Runtime supporting WASIX, WASI and Emscripten

modsurfer - Devtools to validate, audit and investigate WebAssembly binaries.

wizer - The WebAssembly Pre-Initializer

extism - The framework for building with WebAssembly (wasm). Easily load wasm modules, move data, call functions, and build extensible apps.

rr - Record and Replay Framework

js-string-builtins - JS String Builtins

go - The Go programming language

memory-control - A proposal to introduce finer grained control of WebAssembly memory.

iPlug2 - C++ Audio Plug-in Framework for desktop, mobile and web

teavm-wasi - Friendly fork of TeaVM with support for WASI and the WebAssembly Component Model