WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation […] enabling deployment on the web for client and server applications.
Around 2012 Apple announced that it would drop the automatic shipping of Java with its OSX. They did not publicize the reason for this but it is widely considered to be because of security concerns. After this point, plugin based runtimes went out of favor and most browsers are in the process of dropping support for plugin such as Silverlight and Flash. This leaves a hole where runtime plugins had previously been.
Wasm provides a runtime environment with many of the benefits of compiled technologies like Java, Silverlight, and Adobe Flash, but with a
The good news is that C# can already be run on Wasm. There is currently no direct C# to Wasm compiler. However, the current approach is to compile the mono runtime along with CIL assemblies in to Wasm bytecode. This allows for existing C# code to be run on Wasm inside the browser. More detail can be found in the mono-wasm Github repo.
Uno Platform is an ambitious project that aims at providing a C# / XAML based platform for developing apps that target all platforms. This includes browsers, and native iOS/Android. Uno allows developers to define their UI in the platform agnostic markup language XAML, which in turn renders out to the platform’s native UI architecture such as the HTML DOM in browsers. This amazing sample application is a port of the Windows Community Toolkit. It allows direct XAML editing, and binding to manipulate and create UI elements.
In short, these platforms allow C# developers to jump straight in and build web applications with C#. These applications are sandboxed, and fast. However, both these technologies render the UI out to HTML components. C# can be used to manipulate the components, but rendering is still performed by the browser’s inbuilt engine.
Avalonia is a UI API based on Microsoft’s WPF UI API. It doesn’t yet support Wasm. However, this technology stands out as a strong candidate for a UI library that would allow for non HTML DOM rendering inside the browser. This technology may once again allow line of business apps to be built and deployed inside the browser with pixel perfect rendering. The result should be very similar to Microsoft Silverlight.
This article talks about cross platform C# UI technologies in some depth.
Back end and App Development
While browser based front end development is the obvious use case for C# developers, Wasm will not stop there. As mentioned on the website, Wasm is also aimed at “deployment on the web for client and server applications”. This has big implications for C# developers. Wasm is now being deployed to nearly every device in circulation. All new devices will have the Wasm runtime as part of their browser deployment. Even phones such as iPhones and Android phones will have Wasm installed. This means that Wasm is probably already installed on more devices than technologies like Mono. This cannot be said for .NET Core.
It is highly likely that Wasm platforms for building apps outside the browser (non-web embeddings) will emerge, and server side technology will be developed on Wasm. It is also likely that a C# to Wasm compiler will emerge. Wasm may challenge .NET and mono for uptake. Wasm has a long way to go, but it is possible that we may see an ecosystem where modules are built for Wasm and shared across the back end and front end of systems. It will probably mean that modules will be built in various languages such as Rust, and C in the same way that .NET assemblies can currently be built with multiple languages like Python, and Visual Basic. Developers may find themselves on teams where APIs are being built in separate languages concurrently.
It’s time to start experimenting with Wasm and feeling out what can be built with C#. Wasm is likely to change the web development landscape and compiled languages like C# are likely to be at the forefront. C# may once again look like an attractive technology for front end web development. This may well be the next phase of web development that C# developers have been waiting for.