<!-- https://tinyscript.tinyactors.dev/compare/assemblyscript/ -->
# tinyscript and AssemblyScript · 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 AssemblyScript, a TypeScript-like language compiled to WebAssembly: language, speed and when each fits.

AssemblyScript looks like TypeScript and compiles straight to fast WebAssembly. It is a different language, though, and your existing JavaScript won't run in it. Here is when that matters.

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

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

## What AssemblyScript does well

> Writing WebAssembly by hand, or in Rust, is a lot to ask of a TypeScript developer.

AssemblyScript compiles a variant of TypeScript ahead of time to WebAssembly with Binaryen, using WebAssembly's own types such as i32 and f64. There is no interpreter in the way.

For numeric kernels written for WebAssembly, it gives you small, fast modules in a syntax you already read.

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

## A stricter language, not JavaScript

> Code that relies on dynamic objects, closures or promises has nowhere to go in a language without them.

AssemblyScript has no union types but nullable classes, no closures that capture locals, no iterators, no Promises and no dynamic objects, and throwing aborts the program. It says that dynamicness is out by design.

tinyscript runs JavaScript as written, with its objects, closures, generators and promises, and uses TypeScript only as hints. Both end up as WebAssembly; only one runs the code you already have.

- **Dynamic JavaScript is out by design**: Closures that capture locals, iterators, Promises, prototypes and undeclared properties are not supported. Source: [AssemblyScript, implementation status](https://www.assemblyscript.org/status.html)

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

## Which one to choose

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

- **Use AssemblyScript when**: you are writing new, typed code for WebAssembly and want it fast and small.
- **Use tinyscript when**: you run JavaScript that already exists, or that users and models write, with its dynamic objects, closures and promises.

[Visit AssemblyScript](https://www.assemblyscript.org) · [Compare every engine](https://tinyscript.tinyactors.dev/compare/index.md)
