<!-- https://tinyscript.tinyactors.dev/compare/djs/ -->
# tinyscript and djs · Compare

Kind: explanation. For: [Embedder](https://tinyscript.tinyactors.dev/audiences/embedder.xml), [Agent builder](https://tinyscript.tinyactors.dev/audiences/agent-builder.xml), [Platform builder](https://tinyscript.tinyactors.dev/audiences/platform.xml).
Voice: [Dario](https://tinyscript.tinyactors.dev/voices/explanation.xml).

> How tinyscript compares with djs, earendil-works' WebAssembly engine for code mode: language coverage, fuel, snapshots and where each runs.

djs is the engine closest to what tinyscript is for: model-written code, run deterministically, on fuel, in a sandbox. It is also ahead of tinyscript on the language today. Here is where each one fits.

[Skip to the verdict](https://tinyscript.tinyactors.dev/compare/djs/index.md#choose) · [Compare every engine](https://tinyscript.tinyactors.dev/compare/index.md)

<a id="what"></a>

## What djs does well

> An agent's code mode needs an engine that runs what a model wrote, stops it on a budget and never touches the host on its own.

djs is a JavaScript and TypeScript engine in no_std Rust, built mainly for WebAssembly, made to replace QuickJS in the pi coding agent's code mode. Each sandbox is its own WebAssembly instance.

It covers nearly the whole current language in strict mode, erases TypeScript while parsing, and charges fuel per instruction so a budget always stops at the same place. Its sandboxes start in tens of microseconds.

I read its guide expecting a prototype. It is not one: it publishes its test262 numbers, its start-up times and its memory per sandbox.

- **Nearly all of its test262 group**: djs passes 39,325 of the 39,365 test262 tests in its active group, of 53,597 in all; the rest are skipped by design. Source: [djs guide, status](https://github.com/earendil-works/djs/blob/21eda41a0258f8a9501971e0ecf0936f5e5fecdc/docs/guide/status.md)
- **A sandbox in microseconds**: A sandbox is made in 62.2 µs and runs its first program in 85.7 µs, after the module compiles once per process in about 5 ms. Source: [djs guide, status](https://github.com/earendil-works/djs/blob/21eda41a0258f8a9501971e0ecf0936f5e5fecdc/docs/guide/status.md) · [djs, js/README.md](https://github.com/earendil-works/djs/blob/21eda41a0258f8a9501971e0ecf0936f5e5fecdc/js/README.md)

<a id="differences"></a>

## Where tinyscript differs

> Two engines with the same goals still make different bets, and the bets decide where each one fits.

djs bets on WebAssembly around the interpreter: the host's engine is the boundary, and any JavaScript host can load it. tinyscript bets on WebAssembly as the bytecode: a C library in your process, compiling ahead of time.

| Question | djs | tinyscript |
|---|---|---|
| Language today | 39,325 of 39,365 in its test262 group | 62.9% of test262 in strict mode |
| Bounding a call | Deterministic fuel; a sliced run continues | Exact fuel; a run continues where it stopped |
| Saving a run | Heap images in a process; waiting runs across processes | Sessions saved as their values |
| Where it runs | Node.js, Bun, Deno, browsers, Workers, native Rust | A C library and a command-line tool |
| Boundary | One WebAssembly instance per sandbox | A message interface in your process |

Speed is open: both are interpreters, and nobody has run them on the same workloads yet. tinyscript's answer is to emit one WebAssembly module of your whole program, which a host's JIT then compiles.

- **All of test262, in strict mode**: 62.9% (31310 of 49767)
- **Language syntax and semantics**: 85.2% (18969 of 22259)
- **Built-in objects**: 51.2% (12130 of 23692)

How far tinyscript has come on test262 in strict mode, by [its own run](https://github.com/tinyactors-dev/tinyactors/blob/ef90baf70d8974072e9007c482190ec61043ce7c/tinyscript/test262/expected-failures.txt).

<a id="choose"></a>

## Which one to choose

> Most readers need one answer: which engine to try first.

- **Use djs when**: your host is JavaScript (Node.js, Bun, Deno, a browser or Workers) and you want broad language coverage with fuel and snapshots today, and an experimental API is acceptable.
- **Use tinyscript when**: you embed from C, want no WebAssembly engine between your process and the interpreter, and run the same code many times, where compiling it ahead of time pays.

[Visit djs](https://github.com/earendil-works/djs) · [Compare every engine](https://tinyscript.tinyactors.dev/compare/index.md)
