tinyscript and djs

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 verdictCompare every engine

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

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, statusdjs, js/README.md

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.

Questiondjstinyscript
Language today39,325 of 39,365 in its test262 group62.9% of test262 in strict mode
Bounding a callDeterministic fuel; a sliced run continuesExact fuel; a run continues where it stopped
Saving a runHeap images in a process; waiting runs across processesSessions saved as their values
Where it runsNode.js, Bun, Deno, browsers, Workers, native RustA C library and a command-line tool
BoundaryOne WebAssembly instance per sandboxA 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 mode62.9%31,310 of 49,767
Language syntax and semantics85.2%18,969 of 22,259
Built-in objects51.2%12,130 of 23,692
How far tinyscript has come on test262 in strict mode, by its own run.

Which one to choose

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

  • Use djs whenyour 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 whenyou 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 djsCompare every engine