Connecto.rs
This is connect-4 with a Rust core compiled to WASM, wrapped in Typescript, rendered in HTML.
The goal is to encourage more Javascript engineers to write Rust.
Demonstrating the why of writing Rust is outside the scope of this repository, demonstrating all the great things you can do with Rust is also outside the scope as I am in no way an authority on idiomatic Rust.
But if you're already curious about Rust, hopefully this repository will speed up the process of going from whaaa to whoaa.
May the connect-4s be with you.
Outcomes
These are some of the things you will be able to do by the end of this series:
- see similarities and differences between parts of Rust and Javascript
- send data back and forth between the Rust (WASM) and Javascript context
- expose the minimal set of APIs from your Rust code to structure your application
- play connect 4 in a browser
Prerequisites
- Node.js (for running the web-server)
- Rust toolchain (for running the Rust code)
- wasm-pack (for compiling to WASM)
Development
# building the engine cd connecto.rs chmod +x build.sh ./build.sh # starting the node server cd www npm i npm run dev
Directory Structure
connectors/
├─ connecto.rs/ // Rust workspace
│ ├─ build.sh // compiles engine to WASM
│ └─ connectors/
│ ├─ src/lib.rs // Rust entry point
│ └─ src/engine.rs // engine code
└─ www/ // client-side code
Rust for JavaScript Engineers - Blog post series
- Intro ◀──────────────────────── Start here
- All a Board
- Interactivity
Code checkpoints
- Part 0 - Prologue
- Part 1 - Setting the board
- Part 2 - Playing the game
- Part 3 - Winning the game
- Bonus - Dev ops