quickjs-pure
An embeddable JavaScript engine written in pure Rust, aiming at behavioural equivalence with QuickJS.
No C compiler, no bindgen, no FFI: the whole pipeline — lexer, parser, bytecode compiler,
VM, garbage collector — is Rust. That makes it buildable for a target without a C toolchain,
which the original cannot do, and it is why the C ABI is a separate crate
(quickjs-capi) rather than the only way in.
[]
= "0.17.38"
The package is quickjs-pure but the library is quickjs (the plain name is taken on
crates.io by a 2019 FFI wrapper), so the import is:
use ;
let runtime = new;
let mut context = new;
context.eval?;
assert_eq!;
# Ok::
This example lives in examples/embed.rs and is run by the test suite.
How much of JavaScript works
Not a feature list — two measurements, both reproducible on your machine:
| measured | value | |
|---|---|---|
| conformance | test262 test/built-ins (the standard library) |
18351/18351 (100.0%) |
| conformance | test262 test/language (the language) |
23566/23745 (99.2%) |
| surface | properties of intrinsics the reference has | 798/802 in scope |
Both conformance rows are test262, and they are deliberately separate. test/built-ins
is the standard library; test/language is the language itself — parsing, scoping,
closures, classes, async — and it is the harder half. Adding them together would
let the stronger one hide the weaker, which is exactly the mistake this page made when
it published a 99.99% that only ever ran built-ins.
What is not here
Every entry below is a property the reference interpreter owns and this engine does
not. The list is generated from scripts/builtin-surface.py, which enumerates both
engines, so it cannot say a feature is missing after it starts existing:
| why | |
|---|---|
ArrayBuffer.prototype.immutable |
immutable ArrayBuffer proposal; outside requirements.md FR-11 |
ArrayBuffer.prototype.sliceToImmutable |
immutable ArrayBuffer proposal; outside requirements.md FR-11 |
ArrayBuffer.prototype.transferToImmutable |
immutable ArrayBuffer proposal; outside requirements.md FR-11 |
RegExp.prototype.compile |
Annex B compile |
globalThis.Atomics |
M8.5: no threads, so no Atomics (requirements.md FR-11) |
globalThis.SharedArrayBuffer |
M8.5: no threads, so no SharedArrayBuffer |
globalThis.__loadScript |
host global of the reference CLI, not an engine intrinsic |
globalThis.performance |
host global of the reference CLI, not an engine intrinsic |
Two of those are real compatibility losses — the reference has Atomics and
SharedArrayBuffer and this engine does not, because it is single-threaded and has
nothing to wait on. The rest are outside the target.
The conformance number is test262, which is the suite the
language specification's own editors use. A case is counted as passing only when the engine
agrees with it; a case whose feature the engine lacks is counted under that feature, so an
absent feature cannot turn green by being skipped. The full breakdown — every skipped case,
every gap, with reasons — is in
docs/capability-report.md.
Deterministic memory
Reference counting plus a cycle collector, so an object is freed as soon as it becomes
unreachable: there is no tracing pause, and no finalizer whose timing depends on the
allocator. Runtime::run_gc reports what it freed, which makes object lifetime something
the test suite can assert instead of a source of flaky failures.
API shape
Idiomatic Rust rather than a transcription of the C API: Runtime (heap and limits),
Context (a global object plus its builtins), Value, and Context::eval with an Error
enum that separates syntax, exception, and not implemented.
Status
Pre-1.0. The engine executes the language; the API is still moving, and 0.x minor
releases have made breaking changes to it. What that means concretely is in
docs/compatibility.md:
which crates are intended for 1.0, what each promises, and what is explicitly not promised.