Off on a tangent again, WebAssembly

WebAssembly is now has official specifications published by W3C. Highlighted by this article on the register site.

WebAssembly is a standard developed by the W3C WebAssembly Working Group. Today all modern browsers (Chrome, Firefox, Safari, Edge, mobile browsers) and Node.js support it.

Enscripten which in the past was used to convert C/C++ source code to asm.js now also supports converting C/C++ code to WebAssembly code. This also has built in support for Makefile (using ’emmake make’ rather than the normal ‘make’) making porting code easy. Plus it also seems to have inbuilt support for OpenGL so C apps using that can be ported easily.

WebAssembly should allow code to run at near native speed on a users browser, and while it is unlikely to replace existing complex applications I expect most new applications will be written in it. It does not replace javascript yet but interacts with it allowing both tools to be used.

As all of the links references in this post have different locations on github from which to download the Enscripten utilities, I suggest a google search to find the latest, at the time of writing this post the latest installation steps are

git clone https://github.com/emscripten-core/emscripten.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

Sites with good WebAsembly examples

There are lots of posts available on using WebAssembly, these are a few good references.
Full documentation https://developer.mozilla.org/en-US/docs/WebAssembly

An article on using existing C code to webassembly (inclusing using the virtual filesystem) at https://www.smashingmagazine.com/2019/04/webassembly-speed-web-app/

There is this very detailed post on how Ross Smith ported the C++ game Funky Karts to WebAssembly including user input and audio. It also touches on the Makefile syntax needed and covers the issues he had and how they were resolved. As it was written in 2017 WebAssembly has progressed quite a bit
https://www.rossis.red/wasm.html

Another useful reference would be this post here which covers getting aound issues using pointers and arrays between javascript and WebAssembly modules. https://medium.com/@kestrelm/creaturepack-high-performance-2d-webgl-character-animation-with-webassembly-72c436bec86c

I suggest you google a few examples yourselves, there are examples out there of full blown monolithic native Desktop C/C++ applications that have been pretty much just picked up and dropped into a web bwowser.

Why was this post titled off on a tangent again ?

It is something else I want to look into, even though I do not have the time. Plus I need an application to port; although I will probably knock up a few quick gtk applications with menu bars and input areas to see if that ports (as I really don’t want to also start using opengl as each distro ships that differently so it would be a pain [fedora31 for example doesn’t even have opengl, replacing it with mingw]).

So it is added to my todo list along with android app programming (which is on a temporary halt as I want to ditch the java stuff I started and learn to use Kotlin, but got sidetracked by looking at responsive apps google has been pushing in preference to native apps, and slightly lost motivation when the useful app I wanted to create I provided the functionality for in under 5mins coding on my website as a server based app).

So, it is another tangent. Just adding to the list of things I want to learn.

About mark

At work, been working on Tandems for around 30yrs (programming + sysadmin), plus AIX and Solaris sysadmin also thrown in during the last 20yrs; also about 5yrs on MVS (mainly operations and automation but also smp/e work). At home I have been using linux for decades. Programming background is commercially in TAL/COBOL/SCOBOL/C(Tandem); 370 assembler(MVS); C, perl and shell scripting in *nix; and Microsoft Macro Assembler(windows).
This entry was posted in personal. Bookmark the permalink.