<!-- https://tinyscript.tinyactors.dev/compare/scriptc/ -->
# tinyscript and scriptc · 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 scriptc, Vercel's ahead-of-time compiler from TypeScript to native binaries and WASI modules.

scriptc, from Vercel Labs, compiles typed TypeScript ahead of time to a small native binary that starts in milliseconds. tinyscript does its work ahead of time too, but for a different job. Here is which job is yours.

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

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

## What scriptc does well

> Shipping a TypeScript tool usually means shipping Node.js with it, and paying its start-up on every run.

scriptc type-checks your code with the real TypeScript compiler, uses the types to pick native representations, and writes a native executable or a WASI module through LLVM. Untyped code can fall back to an embedded quickjs-ng.

The result is a binary of about 320 KB that uses Node.js APIs. It is experimental, and it is a genuinely different way to run TypeScript.

- **Native start-up in milliseconds**: A compiled binary starts in about 4 ms, against about 35 ms for Node.js. Source: [scriptc, quickstart](https://scriptc.dev/quickstart)

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

## A program, not a sandbox

> Ahead-of-time compilation is only safe to run in your process when the code is yours.

scriptc's output is a program with Node.js APIs for files, processes, the network and C, and its docs don't call it a sandbox. That is the right design for code you wrote.

tinyscript compiles ahead of time for the opposite case: someone else's code, run many times inside your process, where every effect goes through you. Its images are WebAssembly that only reaches the world by asking.

| Question | scriptc | tinyscript |
|---|---|---|
| Output | A native binary or a WASI module | A WebAssembly image your process runs |
| Ambient I/O | Node.js APIs and C FFI | None: every effect is a message |
| eval and new Function | Throw EvalError | Compiled at run time |
| Bounding a call | The operating system's, on its process | Exact fuel; the call continues |

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

## Which one to choose

> Most readers need one answer: which tool fits the code they have.

- **Use scriptc when**: you write typed TypeScript you trust and want a small native binary or WASI module that starts fast and uses Node.js APIs.
- **Use tinyscript when**: the code is someone else's and runs inside your process, many times, under your control.

[Visit scriptc](https://github.com/vercel-labs/scriptc) · [Compare every engine](https://tinyscript.tinyactors.dev/compare/index.md)
