Moving from TypeScript to Rust / WebAssembly

Moving from TypeScript to Rust / WebAssembly

I recently decided to switch the engine of Boardgame Lab from TypeScript to Rust. The application itself is an SPA written in Svelte. I only switched the logic that updates the game state to Rust. Here is a summary of my experience with the transition:

I recently decided to switch the engine of Boardgame Lab from TypeScript to Rust. The application itself is an SPA written in Svelte. I only switched the logic that updates the game state to Rust. Here is a summary of my experience with the transition:

Isomorphic Architecture

One of the advantages of using JavaScript or TypeScript is that you can run the same code on both client and server. For Boardgame Lab, this means that the game state can be updated independently on both sides. This results in a lag-free experience on the client while still using the server as the authoritative source of data.

With WebAssembly taking off, you can get the same advantage writing Rust. Instead of pushing client-side code to the server, we push server-side code to the client by compiling Rust to WebAssembly.

This Rollup plugin allows you to import a Cargo.toml file into your TypeScript codebase, allowing a seamless integration between Rust and TypeScript code. The dev experience is almost as smooth as writing TypeScript itself (for example, the browser refreshes automatically when you change a line of Rust code).

wasm-bindgen facilitates serialization of Rust structs into JSON objects and vice-versa.

Limitations of TypeScript

Coding in TypeScript has been a largely pleasant experience, but switching to Rust immediately brought to light some of the limitations of TypeScript.

typescript rust webassembly

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Rust & WebAssembly para JavaScripters

A lo largo de la charla descubriremos las características más destacables de Rust, sus similitudes y diferencias con JavaScript y veremos qué aporta Rust al futuro de la Web gracias a WebAssembly. Rust es un lenguaje tipado, rápido y seguro, que ha sido diseñado por Mozilla como lenguaje de sistemas, aunque en los últimos tiempos ha ganado mucha popularidad en el terreno del desarrollo Web gracias a WebAssembly, su amplio ecosistema y gran comunidad

Memory Management in WebAssembly with Rust

Hello, folks! your wait is over, we have come up with a new blog on WebAssembly with Rust. In this blog, we will discuss about the memory management in web

WebAssembly with Rust

WebAssembly with Rust. In this tutorial will take us on a journey from the basics of WebAssembly to using WebAssembly to integrate with JavaScript, build complete websites, and even host and interpret in Rust apps.

Learning Rust with TypeScript

Today I’m starting a new tutorial series about "Learning Rust by Contrasting with TypeScript". It’s a complete beginner’s guide to start learning Rust with TypeScript.

How to Compile from Rust to WebAssembly?

If you've written some Rust code, you can compile it into WebAssembly! This WebAssembly tutorial takes you through all you need to know to compile a Rust project to wasm and use it in an existing Web App.