{"id":21633791,"url":"https://github.com/dgroomes/wasm-playground","last_synced_at":"2026-04-12T18:05:14.988Z","repository":{"id":146628247,"uuid":"477147703","full_name":"dgroomes/wasm-playground","owner":"dgroomes","description":"📚 Learning and exploring WebAssembly (Wasm)","archived":false,"fork":false,"pushed_at":"2022-06-28T23:43:43.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T22:39:20.461Z","etag":null,"topics":["web-assembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgroomes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-02T19:07:32.000Z","updated_at":"2024-08-17T15:45:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"4d819516-025c-4100-ad95-eb59d1fb9f90","html_url":"https://github.com/dgroomes/wasm-playground","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dgroomes/wasm-playground","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgroomes%2Fwasm-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgroomes%2Fwasm-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgroomes%2Fwasm-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgroomes%2Fwasm-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgroomes","download_url":"https://codeload.github.com/dgroomes/wasm-playground/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgroomes%2Fwasm-playground/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274026691,"owners_count":25209739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["web-assembly"],"created_at":"2024-11-25T03:13:57.133Z","updated_at":"2026-04-12T18:05:09.930Z","avatar_url":"https://github.com/dgroomes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wasm-playground\n\n📚 Learning and exploring WebAssembly (Wasm).\n\n\n## Description\n\nI'm learning about WebAssembly. In part, by reading the book [The Art of WebAssembly](https://wasmbook.com/).\n\nThis project is laid out in the following file and directory structure:\n\n* `add.wat`\n  * A WAT (WebAssembly Text Format) program that adds two integers.  \n* `add-wat.js`\n  * This is a \"runner\" program. It's a JavaScript/Node program that invokes the WAT-based Wasm module to add two integers.\n    The Node runtime is used as an \"embedding environment\" for the Wasm module.\n* `add-rust/`\n  * A Rust (Cargo) project that produces a Wasm module that adds two integers.\n* `add-rust.js`\n  * This is a \"runner\" program for the Rust-based Wasm module. \n\n\n## Instructions\n\nFollow these instructions to compile and run the WAT-based Wasm program:\n\n1. Install WABT\n   * WABT (pronounced \"wabbit\") is the *The WebAssembly Binary Toolkit*. Find it on GitHub: \u003chttps://github.com/webassembly/wabt\u003e.\n   * Below are the commands I used to install WABT. Choose a directory of your choice. I chose `/Users/davidgroomes/repos/opensource/wabt`.  \n   * ```shell\n     git clone --recurse-submodules https://github.com/WebAssembly/wabt\n     ```\n   * ```shell\n     cd wabt/\n     ```\n   * ```shell\n     mkdir build\n     cd build\n     cmake ..\n     cmake --build .\n     ```\n   * Make sure to add the build directory to the `PATH`. Something like: `export PATH=\"$PATH:/Users/davidgroomes/repos/opensource/wabt/build\"`\n2. Install Node\n   * Use `nvm`. We need Node as an \"embedding environment\" to run a Wasm module.\n3. Compile the WAT source code\n   * ```shell\n     wat2wasm add.wat\n     ```\n4. Run the program\n   * ```shell\n     node add-wat.js 1 2\n     ```\n   * Success! You executed a Wasm module via Node!\n\nNow, let's try a Rust-based Wasm module. Follow these instructions to compile and run the Rust-based Wasm module:\n\n1. Install the `wasm-bind-gen` CLI:\n   * ```shell\n     cargo install -f wasm-bindgen-cli\n     ```\n3. Compile the Rust code to a Wasm module:\n   * ```shell\n     cargo build --manifest-path=rust-add/Cargo.toml --target=wasm32-unknown-unknown\n     ```\n4. Generate the Rust bindings for the Wasm module\n   * ```shell\n     wasm-bindgen --out-dir rust-add/pkg rust-add/target/wasm32-unknown-unknown/debug/rust_add.wasm\n     ```\n5. Run the program:\n   * ```shell\n     node --experimental-wasm-modules --no-warnings add-rust.mjs 1 2\n     ```\n\n\n## Wish List\n\nGeneral clean ups, TODOs and things I wish to implement for this project:\n\n* [x] DONE Write some basic WAT code\n* [ ] Write more WAT code\n* [x] DONE Run a WAT program from a NodeJS embedding environment\n* [ ] Run a WAT program using [wasm3](https://github.com/wasm3/wasm3) (a Wasm interpreter)\n* [x] DONE Compile a \"hello world\" Rust program to Wasm (UPDATE 2022-06-27: I don't want all this web stuff. I don't\n      want the final artifact to be a web page, I want to be able to run it in a NodeJS embedding environment.)\n      How to build a package? I think `wasm-pack build --target bundler`.\n      UPDATE 2: Can I compile the Rust code using `cargo` directly, and use `--target=wasm/32/unknown/unknown` like this \u003chttps://stackoverflow.com/a/71673305/\u003e?\n      UPDATE 3: Yes, Cargo + `wasm-bind-gen` is all I need. Works great (for this toy program at least).\n* [ ] Compile a \"hello world\" Kotlin program to Wasm (This isn't possible right now. Kotlin needs to finalize and release\n      their Wasm stuff. I think it's in flux.)\n* [ ] Compile a \"hello world\" Go program to Wasm\n* [ ] Use ES modules for `add-wat.js`. I want to avoid CommonJS as much as feasible.\n* [ ] Consider splitting into a `wat/` subproject and a `rust/` subproject.\n\n\n## Reference\n\n* [Book: *The Art of WebAssembly*](https://wasmbook.com/)\n* [MDN: *Converting WebAssembly text format to wasm*](https://developer.mozilla.org/en-US/docs/WebAssembly/Text_format_to_wasm)\n* [MDN: *Compiling from Rust to WebAssembly*](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm)\n* [Online book: *Rust and WebAssembly*](https://rustwasm.github.io/docs/book/)\n* [GitHub repo: `wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen)\n  \u003e Facilitating high-level interactions between Wasm modules and JavaScript\n* [Node.js docs: *Wasm modules*](https://nodejs.org/api/esm.html#wasm-modules)\n  * This describes the `--experimental-wasm-modules` flag.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgroomes%2Fwasm-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgroomes%2Fwasm-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgroomes%2Fwasm-playground/lists"}