Autogenerating Rust-JS bindings with UniFFI
Mozilla extended UniFFI, its Rust library for auto-generating foreign-language bindings, to emit JavaScript bindings for Firefox Desktop starting in Firefox 105, replacing error-prone hand-written wrappers that undermined Rust's memory safety. Because JavaScript cannot call C ABI functions directly, Firefox's WebIDL code generator produces only the minimal C++ scaffolding layer, with the idiomatic user API written in JavaScript on top. UniFFI calls are blocking while the Firefox main thread must never block, so every generated JS function returns a promise, with per-function sync/async control planned. The approach shipped the Rust remote-tabs sync engine across Desktop, Android and iOS in Firefox 108.
Related posts
- Bun v0.1.9
Bun mediumAdept
Bun v0.1.9 starts using JavaScriptCore's DOMJIT API to JIT-optimize native functions, making `ptr()` in `bun:ffi` 6-10x faster and `TextEncoder.encodeInto` 1.5-5x faster. To get there, Bun extended DOMJIT to accept Typed Array arguments and to declare more kinds of side effects. Bun now code-generates C++ binding classes and ABI-checked Zig bindings from JavaScript class definitions, an approach inspired by WebIDL, replacing most use of the JSC C API. Other changes include a more reliable, lower-CPU event loop on Linux, about 20% faster `Bun.serve` through better `Headers` handling, native `buffer` and `process` modules, and numerous crash fixes.
- Rewriting Bun in Rust
Bun mediumAdept
Bun, a 535k-line Zig JavaScript runtime, was mechanically ported to Rust over 11 days using about 50 continuously running Claude Code workflows. The motivation was a steady stream of use-after-free, double-free and leak bugs that came from mixing JavaScriptCore's garbage-collected values with manually managed Zig memory. The port was done all at once in a deliberately Zig-shaped style, guided by a porting guide and a lifetimes map, and validated against Bun's language-independent TypeScript test suite. Adversarial review in separate context windows caught bugs such as Box drops before async uv_close, negative-time timespec errors, and eager unwrap_or evaluation; cleanup toward idiomatic, less-unsafe Rust is planned after v1.4.
- Roll your own JavaScript runtime
Deno mediumAdeptA minimal JavaScript runtime called runjs can be built in Rust by combining the deno_core crate, which wraps a V8 isolate in a JsRuntime, with a single-threaded tokio runtime as the event loop. The tutorial loads and evaluates ES modules from disk, adds a console API in a bundled runtime.js, and exposes async and sync filesystem functions to JavaScript via #[op2] ops registered through the extension! macro. deno_core handles marshalling between JS Promises and Rust Futures, so each new native API needs only a small amount of glue code.
- Bun 1.4
Bun mediumAdept
Bun 1.4 adds 1,517 newly passing Node.js test-suite tests, fixes over 2,900 issues, and rewrites Bun from Zig to Rust. JavaScriptCore now uses an extended mimalloc instead of libpas, adding a scavenger thread, partial page clearing and better lazy zeroing. Together with GC timer tuning, segmented-array Strong roots and fewer futex calls, this cuts idle CPU 5x, HTTP server peak memory 13–48%, and Linux startup time in half. New APIs include Bun.Image, Bun.WebView, Bun.markdown, Bun.cron and Bun.Terminal, plus Markdown CPU, heap and bundle profiles and a cross-platform memoryPressure event built on kqueue, PSI and Windows resource notifications.
- Announcing Stable V8 Bindings for Rust
Deno mediumAdeptRusty V8, Deno's zero-overhead Rust bindings to V8's C++ API, is now stable and skips 1.0 to align with Chrome versioning, starting at 129.0.0. The crate integrates V8's build into Cargo and supports custom runtimes, WebAssembly, the V8 Inspector, the Fast API and cppgc garbage collection. Rust's scope-tied `Local<T>` handles catch invalid handle use at compile time, which C++ embedders must manage by hand. The major version bumps every 4 weeks with each V8 upgrade, so breaking changes follow semver and land only alongside V8 updates.