What Language Should I use for WASM

11th Mar 2022

What Language Should I use for WASM

There is no doubt in my mind that WASM will become a large part of my future toolkit. The performance benefits for serverless functions will directly equate to cost savings. Then the performance benefits for user interfaces will directly equate to increased revenue.

The problem is, there are a few languages to choose from when programming for a WASM environment. I won't be able to stay proficient in many so do I choose to invest my time in C++, Rust, Go or even F#?

First, I will spend a bit of time dipping my toes into each language. There are certain benefits to using each; I expect it will be helpful for me to have a shallow understanding of them anyway.

C++

I have gone through this excellent resource to familiarize myself with C++ https://www.learncpp.com and played around with Emscripten.

There are many powerful usages of C++, making this an attractive option. I also work with ESP32 microcontrollers and use C++ for this development.

To name a couple.

FFMPEG has been ported to wasm. I plan to convert media within the browser before uploading to relieve this burden from the server.

OpenCV (Open Source Computer Vision) is another library written in C++ and usable with wasm. I have a few plans to integrate OpenCV with some side projects.

Then there is TensorFlow which now has the option to use wasm backend. It looks like this has been written in C++.

I know I don't necessarily have to understand C++ to use these tools, it would help integrating with them if I do. Debugging issues would be easier and enhancing them simpler.

C++ however has a bad rep for memory management and maintainability so I am nervous about doing much with it unless I dedicate a significant amount of time to learn it well.

Rust

Rust is mentioned a lot when it comes to wasm. The tooling for Rust is really good. It has wasm-pack which deals with the interfaces between JavaScript and the compiled wasm binary.

Whilst the tooling is good, I have found a lack of official native SDK support for some of the platforms and libraries I might want to integrate with. Firebase and Espressif ESP32 are the ones I have struggled to find good solutions for.

This would mean more effort to integrate with these platforms.

Go

I am just starting to look at Go. It looks like it ticks many of the boxes I have mentioned above. It is easier to work with than C++, you can use it with embedded devices, and Firebase has an official Go server library.

I will continue my research here to see how good these integrations are.

F#

F# is the final option I have on the table. I don't have a huge amount of experience with F# but TherapyPal uses F# for all their code so I need to learn it enough to help out there.

It looks like there is a tool for compiling to wasm in the form of Bolero.

Finally

As you can probably tell from my thought process above, there are a number of areas to consider. It has been helpful to get them written down. There is a lot of learning to do and I am excited about the journey!

This series: