Has It Really Been Two Years?!

I find it funny that in my last post, I said I’d hopefully write another post before I hit the 1 year anniversary of said post.

So yeah, two years later… I got kinda bored with crypto-related stuff and I haven’t played around much more with my 8-Pi Kubernetes cluster. However, I **have** been plugging along working with Rust and WASM. If you’re unfamiliar with WASM, it’s basically a Virtual Machine that runs in the browser, and multiple programming languages can be compiled to run on it (including C++ and Rust). Think Java’s Virtual Machine, except more than just Java can run on it. I’m fascinated by it because it enables me to play with web development without leaving my comfort zone of Rust and C++, and in turn enabling my programs to run on just about any platform that has a modern web browser.

Now, I still haven’t done anything super interesting with it, but I did manage to get a working WASM web app live and running, complete with a graphical user interface, courtesy of the awesome “egui” crate/library for Rust. Aside from some glue logic code auto-generated by the Trunk tool, (a tool for building and packaging Rust WASM apps for deployment to a web server), I barely had to touch any JavaScript or HTML. I was able to write the business logic and GUI for my app entirely in Rust. The cool part here, to me at least, is that this exact same code, with minimal (if any) modification, can easily be recompiled to run natively on Windows, Mac, and Linux.

If you’re interested, I’ve uploaded it here. It’s a very basic interpreter for the toy/joke programming language “Brainf*ck”. (If you’d like to learn more, the Wiki page is a great start). BF is a very simple language to implement in terms of operations, so it was an easy, but non-trivial (mostly), thing to target for my first Rust/WASM web app. You can interact with it by either entering some BF code into the text box, or by uploading a plaintext file containing BF code. Right now, my implementation really just supports math and print operations. The ‘,’ operator, which is used in BF to read in a byte from the user, is technically supported, but I haven’t yet gotten it working from this web GUI. So for now, you can run basic math operations and make it print things.

Honestly, it was harder to implement the file picker than any other part of this project. I found a crate called “rfd” that implements file picker dialogs; it was also compatible with WASM. However, that took me down a rabbit hole of having to get a little comfortable with async Rust and how to handle transferring data from that part of the code to the main portion of the program.

Long story short, it reminded me why I have favored bare-metal coding on microcontrollers over web/application development for most of my career thus far.

Now that I have a new hyperfixation in the form of Rust and WASM, I’ll probably resume posting here more frequently, and hopefully with more Rust/WASM things to show off.

Leave a Reply

Your email address will not be published. Required fields are marked *