Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://davidmcneil.github.io/the-rusty-web
Targeting the web with Rust.
https://davidmcneil.github.io/the-rusty-web
asmjs javascript rust web webassembly
Last synced: 1 day ago
JSON representation
Targeting the web with Rust.
- Host: GitHub
- URL: https://davidmcneil.github.io/the-rusty-web
- Owner: davidMcneil
- Created: 2017-02-09T18:26:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-16T17:10:29.000Z (almost 6 years ago)
- Last Synced: 2024-08-21T06:31:54.880Z (4 months ago)
- Topics: asmjs, javascript, rust, web, webassembly
- Language: JavaScript
- Homepage: https://davidmcneil.github.io/the-rusty-web/
- Size: 4.63 MB
- Stars: 126
- Watchers: 4
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-wasm - Rusty Web
README
# The Rusty Web
[![Website](https://img.shields.io/badge/website-The_Rusty_Web-red.svg)](https://davidmcneil.github.io/the-rusty-web/)
[![Guide](https://img.shields.io/badge/guide-GitBook-blue.svg)](https://davidmcneil.gitbooks.io/the-rusty-web/content/)_Note: The contents of this repo are now significantly outdated. Check out [rustwasm](https://github.com/rustwasm/team) for the latest and greatest on how to integrate Rust ans WebAssembly._
Discussion on [Hacker News](https://news.ycombinator.com/item?id=13820175).
## About
This project demonstrates a complete, albeit simple, example of integrating
[Rust](https://www.rust-lang.org) code into a web application. This is accomplished by compiling
Rust to [asm.js](http://asmjs.org/) or [WebAssembly](http://webassembly.org/). The
basic design pattern this project explores uses Rust to implement CPU bound portions of an app while
using existing web technologies to handle user facing, I/O bound pieces. The
[guide](https://davidmcneil.gitbooks.io/the-rusty-web/content/) explores this design pattern in
detail.The project compares implementations of the
[k-means clustering](https://en.wikipedia.org/wiki/K-means_clustering) algorithm (this example's
CPU bound task) applied to an image. The algorithm gives the resulting image a softened, painted look.## Setup
### Dependencies
See the [guide](https://davidmcneil.gitbooks.io/the-rusty-web/content/setup-and-hello-world.html)
for steps on installing the dependencies.- [Rust](https://www.rust-lang.org)
- [Node](https://nodejs.org)
- [Emscripten](http://emscripten.org)### Running the Project Natively
From the top level of the project run
> cargo run
or
> cargo run --release
The resulting painted image can be found at _img/out.jpg_.
### Running on the Web
From the top level of the project...
Build the asm.js version
> cargo build --release --target asmjs-unknown-emscripten
Build the WebAssembly version
> cargo build --release --target wasm32-unknown-emscripten
From the _website/_ directory...
Install node dependencies
> npm install
Build the website (build results can be found in _website/dist_)
> npm run build
or build the website in release mode
> npm run build-release
or start a web server, website is served at [http://localhost:9000/](http://localhost:9000/)
> npm run start