Maker of open-source software and hardware.

Experimenting with transpiling C# to WebAssembly

Feature image

I'm not a C# programmer. The last time I used .NET was more than a decade ago when I wrote Visual Basic code. But we need an implementation of the LZO compression algorithm that is MIT/BSD-licensed, and the only one we could find is written in C#, based of a description of the algorithm instead of a GPL implementation.

I came across an article describing CoreRT, which translates C# code into cross-platform C++. When I went to the GitHub page, I discovered that it can also transpile to WebAssembly. I've never worked with WebAssembly before, but this seems as good a time as any to give it a try.

I started by installing the prerequisites on Ubuntu 18.04. Unfortunately the prerequisites are for 16.04. I attempted to install the latest version of clang, but got some weird errors, so now I'm installing the specified versions.

If all goes well, I'm hoping to generate either a WebAssembly module of the LZO algorithm or a C++ static library that I can then write a NodeJS wrapper for. I have a feeling the solution may just be too bloated, as I just got a Hello World app compiled that is 14MB in size. 😕️