<!-- https://tinyscript.tinyactors.dev/compare/isolates/ -->
# tinyscript and V8 isolates · 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 V8 isolates, as Cloudflare Workers and isolated-vm use them: speed, security boundary, memory and bounding a call.

V8 isolates power Cloudflare Workers, and they are the fastest way to run JavaScript there is. Running untrusted code in them safely takes more than an isolate, by V8's own account. Here is the difference.

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

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

## What V8 isolates do well

> Most JavaScript in the world was written for V8, and expects all of the language at full speed.

An isolate is an instance of V8 with completely separate state; an embedder can make many and run them on parallel threads. You get the whole current language and WebAssembly, compiled by one of the best JITs there is.

Cloudflare runs many tenants' isolates in one process, and that model is proven at enormous scale. Nothing tinyscript does will match V8's peak speed on long-running hot code.

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

## An isolate is not a boundary alone

> Putting code you don't trust in an isolate feels like a sandbox, and V8 says it isn't one.

V8's security policy says embedders running untrusted code must isolate V8 inside an OS-sandboxed process. Cloudflare does exactly that, and adds cordons, seccomp, frozen timers and fast patching on top.

tinyscript has no ambient capability to take away: it only has the buffer you gave it and the messages you answer. It has no external audit yet, so treat that as design, not proof.

- **V8 asks for a process sandbox**: Embedders executing untrusted code must always isolate V8 inside an OS-sandboxed process; a V8 isolate is not a process-level boundary. Source: [V8, SECURITY.md](https://chromium.googlesource.com/v8/v8/+/HEAD/SECURITY.md)
- **A call is terminated, not paused**: TerminateExecution forcefully ends the current thread of JavaScript execution with an uncatchable exception. Source: [V8 API, v8::Isolate](https://v8.github.io/api/head/classv8_1_1Isolate.html)

| Question | V8 isolates | tinyscript |
|---|---|---|
| Language and speed | All of it, JIT-compiled | 62.9% of test262; an interpreter |
| Boundary | An isolate inside a sandboxed process | A message interface by construction |
| Memory | Around 3 MB each, Cloudflare said in 2018 | A realm's heap and about 166 KB of stacks |
| Bounding a call | A time limit that terminates | Exact fuel; the call continues |
| Snapshots | Start-up snapshots, trusted input only | Sessions saved as their values |

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

## Which one to choose

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

- **Use V8 isolates when**: you need the whole language at full speed, can run each trust level in its own sandboxed process, and a call that runs too long may simply be killed.
- **Use tinyscript when**: you need hundreds of thousands of sessions in one process, every effect under your control, and calls you can pause and continue.

[Visit V8](https://v8.dev) · [Compare every engine](https://tinyscript.tinyactors.dev/compare/index.md)
