All Projects → stefano → Wasm Forth

stefano / Wasm Forth

Licence: gpl-3.0
A Forth implementation compiling to WebAssembly.

Programming Languages

python
139335 projects - #7 most used programming language
forth
179 projects

Projects that are alternatives of or similar to Wasm Forth

Webassemblyjs
Toolchain for WebAssembly
Stars: ✭ 566 (+515.22%)
Mutual labels:  compiler, webassembly, wasm, interpreter
Grain
The Grain compiler toolchain and CLI. Home of the modern web staple. 🌾
Stars: ✭ 2,199 (+2290.22%)
Mutual labels:  compiler, webassembly, wasm
Alchemyvm
WebAssembly Virtual Machine Built In Elixir
Stars: ✭ 176 (+91.3%)
Mutual labels:  webassembly, wasm, interpreter
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (+2197.83%)
Mutual labels:  compiler, webassembly, wasm
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+14195.65%)
Mutual labels:  compiler, webassembly, wasm
Wasm Micro Runtime
WebAssembly Micro Runtime (WAMR)
Stars: ✭ 2,440 (+2552.17%)
Mutual labels:  webassembly, wasm, interpreter
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (+92.39%)
Mutual labels:  compiler, webassembly, wasm
Wain
WebAssembly implementation from scratch in Safe Rust with zero dependencies
Stars: ✭ 160 (+73.91%)
Mutual labels:  webassembly, wasm, interpreter
Wasm3
🚀 The fastest WebAssembly interpreter, and the most universal runtime
Stars: ✭ 4,375 (+4655.43%)
Mutual labels:  webassembly, wasm, interpreter
Jwebassembly
Java bytecode to WebAssembly compiler
Stars: ✭ 426 (+363.04%)
Mutual labels:  compiler, webassembly, wasm
warpy
WebAssembly interpreter in RPython
Stars: ✭ 54 (-41.3%)
Mutual labels:  interpreter, webassembly, wasm
Winter
Haskell port of the WebAssembly OCaml reference interpreter
Stars: ✭ 42 (-54.35%)
Mutual labels:  webassembly, wasm, interpreter
Viper
[WIP] A Pythonesque language with a design that focuses on efficiency and expressiveness. Compiles to WebAssembly
Stars: ✭ 23 (-75%)
Mutual labels:  compiler, webassembly, wasm
Wasmjit
Small Embeddable WebAssembly Runtime
Stars: ✭ 1,063 (+1055.43%)
Mutual labels:  webassembly, wasm, interpreter
Muze
Composable data visualisation library for web with a data-first approach now powered by WebAssembly
Stars: ✭ 1,153 (+1153.26%)
Mutual labels:  webassembly, wasm
Dockerdot
🐳 dockerdot shows dockerfile dependenciy graph. This is useful to understand how build dockerfile. This uses Go WebAssembly + BuildKit package.
Stars: ✭ 65 (-29.35%)
Mutual labels:  webassembly, wasm
Web Audio Javascript Webassembly Sdk Interactive Audio
🌐 Superpowered Web Audio JavaScript and WebAssembly SDK for modern web browsers. Allows developers to implement low-latency interactive audio features into web sites and web apps with a friendly Javascript API. https://superpowered.com
Stars: ✭ 68 (-26.09%)
Mutual labels:  webassembly, wasm
Web Dsp
A client-side signal processing library utilizing the power of WebAssembly (.wasm)
Stars: ✭ 1,278 (+1289.13%)
Mutual labels:  webassembly, wasm
Wasmer Python
🐍🕸 WebAssembly runtime for Python
Stars: ✭ 1,131 (+1129.35%)
Mutual labels:  webassembly, wasm
Veracruz
Main repository for the Veracruz privacy-preserving compute project.
Stars: ✭ 71 (-22.83%)
Mutual labels:  webassembly, wasm

WASM Forth

A Forth implementation compiling to WebAssembly.

It includes an ANS Forth standard environment containing all the CORE words. The system has a fixed amount of memory available, currently 128 MB.

Interaction with Javascript at the moment is limited to textual input (using WasmForth.source) and output (through the write configuration parameter passed to WasmForth.boot).

Using the included (optional) virtual DOM library it's possible to write interactive web apps. See the code in examples/todomvc/ for an example TODO list web app fully implemented in Forth.

Installation

$ npm install wasm-forth

Usage

The following code instantiates the interpreter and runs a program that prints "Hello, World!" to the console:

import * as WasmForth from 'wasm-forth';
import wasmURL from 'wasm-forth/dist/kernel.wasm';
import coreURL from 'wasm-forth/dist/core.f';
import vdomURL from 'wasm-forth/dist/vdom.f';

WasmForth.boot({
    wasmURL,
    sources: [coreURL, vdomURL],
    write: (text) => {
        console.log(text);
    }
}).then(() => {
    WasmForth.source(': HELLO S" Hello, World!" TYPE ; HELLO\n');
});

WasmForth.boot({ ... }) initializes the system and returns a Promise. Once resolved, it's possible to interpret forth code by passing it to WasmForth.source(string). Note that the string passed must end with a newline.

WasmForth.boot accepts a configuration object with 3 required parameters:

  • wasmURL: URL where to fetch the "kernel.wasm" included in the NPM package.
  • sources: a list of URLs where to fetch the forth "core.f" included in the NPM package.
  • write: a function that will be called when the forth code needs to output text.

If you're using webpack, you can use the file-loader (https://github.com/webpack-contrib/file-loader) plugin to distribute kernel.wasm, core.f and vdom.f.

You can also use this library without a module bundler by loading it in a <script> tag.

See https://github.com/stefano/wasm-forth/tree/master/examples/webpack for an example usage with webpack, and https://github.com/stefano/wasm-forth/tree/master/examples/script for an example usage as a <script> tag.

See https://github.com/stefano/wasm-forth/tree/master/examples/todomvc for an example of a full web app that interacts with the DOM.

Building from source

To build the forth kernel distribution and the interactive environment (see below), you will first need to install binaryen (https://github.com/WebAssembly/binaryen) and ensure that libbinaryen.so is in the library path (LD_LIBRARY_PATH).

Then build the kernel (Python 3.6 is required):

$ python3.6 -m venv env
$ source env/bin/activate
$ python setup.py build_ext -L path/to/binaryen/lib/
$ python setup.py develop
$ python kernel
$ npm install
$ npm run build # or 'npm run watch'

Interactive Environment

This repository also contains a REPL static page (see the repl directory). To serve it locally, follow the instructions above and then run the following command:

$ python kernel --demo-repl

The REPL will be served at http://localhost:8080/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].