Rewrite of TMT in Rust/Wasm? What good can it bring?

Hi all.
After hearing about Rust and its ability to generate Web Assembly code, which can be run in browsers, I decided to make TMT-like engine in Rust. The obvious start is rewrite of break_eternity.js, the big number library used in TMT. And after testing, I can say this was a good decision. As a test I decided to measure time in ms which is required to tetrate 5000 floats from range [1, 5) with height 2 and payload from range [1, 5).
Here’s break_eternty.js:
And here’s my port of break_eternity.js in Rust, with O3 and LTO:
(forgive the bigger sample size, I went to the kitchen to grab some food)

As you can see, time needed to complete task was approximately 3 times shorter in Rust/Wasm than in JS. What does it mean for normal player, who doesn’t create games but play them? It means few things:

  • For people who play on phone, lesser usage of battery, which means more time playing

  • Bigger games can be created without lag

  • People on weaker machines will also be able to play bigger mods without lag

And now the con: Already existing games can’t use this. JS <=> Wasm access is still slow, so it’s not as easy as drop-in replacement. Here’s the good news. I’m making (or at least trying to make) a TMT-like engine in Rust using Yew framework. I hope it’s matter of when, not if. But why as a game maker should I use Rust? Well, in addition to being fast, Rust is also a strongly typed language, which may sound like you lose much freedom, but it also can prevent game-breaking bugs while still writing code. And compilation to Wasm is not so long. The debug mode of smaller apps takes less than 0.1 of second. And release mode takes something like 10 seconds. What are your thoughts? Write them here if you like.


This sounds interesting. Theoretically, something like The Tree of Life could run decently on my computer without needing to remove layers (it’s usually in the 14-17 ms/tick range), would also likely help with ensuring Plague Tree can go on longer without lag (17 ms/tick out of Booster Vaccine, 20 ms/tick inside of it).