cgm616 / calc_rs

A wasm-powered web-based calculator. Online at http://calc.cgm616.me!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

calc_rs

Travis Website License

calc_rs is a web-based, commandline-esque calculator built with WebAssembly and Rust. Zero Javascript was written in the course of this project. A demo is available here: calc.cgm616.me.

Why?

Truthfully, this project isn't very useful. Instead, it's more of an exercise to see how complex of a web application can be built using only Rust, some html, and some css, and to see how easy/hard it is. The intention was also to improve my html and css skills.

Overall, it was a great experience. Stdweb and cargo-web make the Rust -> web process extremely easy, and WebAssembly itself improves web development for me by a couple orders of magnitude. Bypassing the process of learning new tools and ecosystems, and what (to me) is the extremely confusing world of npm and Node, I was able to instead use Rust libraries to cover the functionality I wanted. Instead of rolling my own parsing, I was able to use pest, which I had experimented with in the past. There were no catches with using Rust crates, and it "just worked."

Built with

calc_rs uses tools on the cutting edge of WebAssembly development.

  • cargo-web, a commandline tool for compiling Rust to the client side web
  • stdweb, a standard library for the web
  • pest, a PEG parser for Rust

Building

In case you want to build calc_rs yourself, first install the nightly Rust compiler using rustup.

> curl https://sh.rustup.rs -sSf | sh
> rustup default nightly

Then, install cargo-web, a tool for building client-side web applications with Rust.

> cargo install cargo-web

Finally, clone the project and build it.

> git clone https://github.com/cgm616/calc_rs
> cd calc_rs
> cargo web build --target=wasm32-unknown-unknown

A fully static site will be generated into the ./target/deploy directory. In case you want to develop calc_rs, it is easier to set up cargo-web to watch the directory and rebuild on changes.

> cargo web start --target=wasm32-unknown-unknown

A server will be running at [::1]:8000 with calc_rs.

About

A wasm-powered web-based calculator. Online at http://calc.cgm616.me!

License:MIT License


Languages

Language:Rust 92.3%Language:CSS 4.1%Language:Shell 1.8%Language:HTML 1.8%