tinyscript and scriptc

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

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

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.

Questionscriptctinyscript
OutputA native binary or a WASI moduleA WebAssembly image your process runs
Ambient I/ONode.js APIs and C FFINone: every effect is a message
eval and new FunctionThrow EvalErrorCompiled at run time
Bounding a callThe operating system's, on its processExact fuel; the call continues

Which one to choose

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

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

Visit scriptcCompare every engine