assemblyscript/README.md

69 lines
2.5 KiB
Markdown
Raw Normal View History

2017-12-15 15:00:19 +01:00
![](https://s.gravatar.com/avatar/f105de3decfafc734b8eabe9a960b25d?size=64) AssemblyScript NEXT
=================
2017-09-28 13:08:25 +02:00
2017-12-15 15:00:19 +01:00
[![Build Status](https://travis-ci.org/AssemblyScript/assemblyscript.svg?branch=master)](https://travis-ci.org/AssemblyScript/assemblyscript)
2017-12-02 20:58:39 +01:00
**AssemblyScript** compiles strictly typed [TypeScript](http://www.typescriptlang.org) to [WebAssembly](http://webassembly.org) using [Binaryen](https://github.com/WebAssembly/binaryen). Unlike other toolchains, `asc` generates minimal WebAssembly modules while being just an `npm install` away.
2017-12-15 15:00:19 +01:00
2017-12-14 16:50:59 +01:00
Examples
--------
A few early examples to get an idea:
* **[Conway's Game of Life](./examples/game-of-life)**<br />
Continuously updates the cellular automaton and visualizes its state on a canvas.
* **[i64 polyfill](./examples/i64-polyfill)**<br />
Exposes WebAssembly's i64 operations to JavaScript using 32-bit integers (low and high bits).
* **[PSON decoder](./examples/pson)**<br />
A PSON decoder implemented in AssemblyScript.
* **[TLSF memory allocator](./examples/tlsf)**<br />
2018-02-01 17:35:51 +01:00
An implementation of the TLSF memory allocator in AssemblyScript.
* **[μgc garbage collector](./examples/ugc)**<br />
A port of μgc to AssemblyScript.
Or browse the [compiler tests](./tests/compiler) for a more in-depth overview of what's supported already. One of them is a [showcase](./tests/compiler/showcase.ts).
2017-12-05 13:35:14 +01:00
Getting started
---------------
Note that this version of the compiler is relatively new and does not yet support some features a TypeScript programmer might expect, e.g., strings, arrays and classes. It is not on [npm](https://www.npmjs.com/package/assemblyscript), yet, but you can already try it out today:
2017-12-05 13:35:14 +01:00
```
2017-12-15 17:23:04 +01:00
$> git clone https://github.com/AssemblyScript/assemblyscript.git
$> cd assemblyscript
2017-12-05 13:35:14 +01:00
$> npm install
$> npm link
2017-12-05 13:35:14 +01:00
```
2017-12-13 04:46:05 +01:00
Author your module using either
* the [assembly definitions](./std/assembly.d.ts) ([base config](./std/assembly.json)) if all you care about is targeting WebAssembly/asm.js or
* the [portable definitions](./std/portable.d.ts) ([base config](./std/portable.json)) if you also want to compile to JavaScript using `tsc`
and run:
2017-12-05 13:35:14 +01:00
```
$> asc yourModule.ts
2017-12-05 13:35:14 +01:00
```
See [the AssemblyScript wiki](https://github.com/AssemblyScript/assemblyscript/wiki) for additional documentation.
Building
--------
Building an UMD bundle to `dist/assemblyscript.js` ([binaryen.js](https://github.com/AssemblyScript/binaryen.js) remains an external dependency):
```
$> npm run build
```
Running the [tests](./tests):
```
$> npm test
```