Native start-up in milliseconds
A compiled binary starts in about 4 ms, against about 35 ms for Node.js.
Source:scriptc, quickstart
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.
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.
A compiled binary starts in about 4 ms, against about 35 ms for Node.js.
Source:scriptc, quickstart
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 |
Most readers need one answer: which tool fits the code they have.