AssemblyScript NEXT
AssemblyScript is a new compiler targeting WebAssembly while utilizing TypeScript's syntax and node's vibrant ecosystem. Instead of requiring complex toolchains to set up, you can simply npm install
it - or run it in a browser.
Note, though, that this version of the compiler (0.5.0, NEXT) is relatively new and does not yet support some features a TypeScript programmer might expect, e.g., strings, arrays and classes.
See the AssemblyScript wiki for additional information and documentation.
How does it work?
By compiling syntactially (not necessarily semantically) valid TypeScript to Binaryen IR, the resulting module can be validated, optimized, emitted in WebAssembly text or binary format and converted to asm.js as a polyfill.
Examples
A few early examples to get an idea:
- Conway's Game of Life as seen on dcode.io
- i64 polyfill using 32-bit integers
Getting started
This version of the compiler is not on npm, yet, but if you'd like to try it today or even plan to contribute, this is how you do it:
$> git clone https://github.com/AssemblyScript/next.git
$> cd next
$> npm install
Author your module using either
- the assembly definitions (base config) if all you care about is targeting WebAssembly/asm.js or
- the portable definitions (base config) if you also want to compile to JavaScript using
tsc
and run:
$> node bin/asc yourModule.ts
Building
Building an UMD bundle to dist/assemblyscript.js
(does not bundle binaryen.js):
$> npm run build
Running the tests:
$> npm test