

























Deno is a modern, zero-config JavaScript runtime written in Rust. At its core is Rusty V8, a library that provides high-quality, zero-overhead Rust bindings to V8’s C++ API. Over the past five years, Rusty V8 has undergone nearly 150 releases, racking up more than 3.1 million downloads on crates.io. Today, we’re excited to announce a major milestone: Rusty V8 is now stable and production-ready.
While we’d love to mark this moment with a “1.0” release, Rusty V8 is skipping version 1.0 entirely. Instead, we’re aligning with Chrome’s versioning scheme to stay in sync with V8. The first stable release of Rusty V8 will be version 129.0.0, in line with Chrome 129. This version guarantees API stability, moving us beyond years of 0.x releases, and solidifies Rusty V8 as a dependable tool for developers building on top of V8.
Rusty V8 gives Rust developers direct, zero-overhead access to V8’s C++ API. It stands out for its completeness and seamless integration with high-performance environments. A key feature is Rusty V8’s automatic integration of V8’s complex build system into Cargo, allowing developers to easily embed V8 in Rust projects without manual setup. With Rusty V8, you can:
cppgc garbage collector helps manage memory efficiently, reducing the
need for manual memory handling in complex applications.The journey to Rusty V8 started in 2015, when I was experimenting with building a JavaScript runtime in Go using a library called v8worker. Eventually, v8worker was used in the first Deno demo. However, as Deno evolved, it became clear that Go wasn’t the right fit for the project because of worries that Go’s own GC would conflict poorly with V8’s.
In late 2019, Deno co-founder Bert Belder led the effort to create a direct Rust binding to V8. The challenge was to bind V8’s complex C++ API to Rust without compromising on performance or safety. After much effort, Rusty V8 was born—a zero-overhead Rust binding to V8 that provides full control over V8, while ensuring memory safety through Rust’s ownership model.
Here’s a simple example of how you can embed JavaScript in a Rust program using Rusty V8:
fn main() { let platform = v8::new_default_platform(0, false).make_shared(); v8::V8::initialize_platform(platform); v8::V8::initialize(); let isolate = &mut v8::Isolate::new(v8::CreateParams::default()); let handle_scope = &mut v8::HandleScope::new(isolate); let context = v8::Context::new(handle_scope, Default::default()); let scope = &mut v8::ContextScope::new(handle_scope, context); let code = v8::String::new(scope, "'Hello' + ' World!'").unwrap(); let script = v8::Script::compile(scope, code, None).unwrap(); let result = script.run(scope).unwrap(); let result = result.to_string(scope).unwrap(); println!("{}", result.to_rust_string_lossy(scope)); }
Rusty V8’s memory safety features are a core advantage over the C++ API. For
example, in Rust, handles like Local<T> are tied to specific scopes and
enforced at compile time. This prevents bugs caused by using or returning
invalid handles—something that C++ developers must manage manually. In Rust, if
you attempt to use a Local<T> outside its scope, the compiler will catch the
mistake.
Here’s a quick example of Rust preventing invalid handle usage:
let isolate = &mut v8::Isolate::new(Default::default()); { let scope1 = &mut v8::HandleScope::new(isolate); let local = v8::Integer::new(scope1, 123); let invalid_local = { let scope2 = &mut v8::HandleScope::new(scope1); v8::Integer::new(scope2, 456) }; }
To keep in sync with V8, Rusty V8 will follow Chrome’s versioning scheme. The first stable release is version 129.0.0, corresponding to Chrome 129. While V8 does not follow semantic versioning (semver) and can introduce breaking changes even in minor versions, Rusty V8 will follow semver to ensure compatibility and stability for Rust developers.
Every 4 weeks, Rusty V8 will upgrade its V8 dependency and bump its major version. This means breaking changes to the Rusty V8 API will only happen when V8 upgrades, and the version will always reflect the underlying V8 version.
Rusty V8 is now a stable, production-ready library for building high-performance JavaScript and WebAssembly runtimes in Rust. Whether you’re creating custom JavaScript runtimes, embedding JS in Rust-backed apps, or exploring server-side JavaScript applications, Rusty V8 provides the flexibility of V8 with the safety and performance guarantees of Rust.
Dive deeper by exploring the full documentation at docs.rs/v8.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。