WebAssembly may be the most exciting technology for C# developers to emerge in recent times. Browser based applications have been developed in JavaScript, or languages that transpile to JavaScript since the early days of the web. This has meant that C# developers have either needed to work with two or more different languages, or avoid browser based development altogether. Wasm may change all of this by being a bridge for .NET based development in browsers.

 

Background

HTML was originally developed by Tim Berners-Lee and published around 1995. Its original purpose was to display static and formatted text and image content that could be displayed in a web browser. Several companies have implemented browsers based on the HTML standard. In order to make web content more dynamic, JavaScript was created as a “collage language” where code could be written to dynamically manipulate the HTML document object model. This was first added to Netscape Navigator and was loosely based on Java syntax. Other browsers have added dynamic languages ​​and Microsoft has added JScript to their Internet Explorer browser.

Previously, the Java Runtime Environment and the programming language had been created, allowing cross-platform code to be executed on major operating systems. Java applets were compiled sets that could be integrated into a web page. The browsers made it possible to control part of the browser canvas for graphic rendering. Java differs from JavaScript in that it does not need to manipulate the HTML DOM. It could render its own graphics and avoid rendering differences between different operating systems and browsers. However, Java applets did not gain much traction in the web community after the first few days.

For many years, browser plug-in runtime technologies like Adobe Flash (1996) and Microsoft Silverlight (2007) were popular means of deploying rich web applications in the browser. These technologies worked in the same way as Java applets. The web browser gave canvas control to these plugins and also allowed them to manipulate the HTML DOM via JavaScript. This meant that developers could code in the language of their choice and make pixel-perfect user interfaces on different platforms.

Around 2012, Apple announced that it would abandon Java automatic shipping with its OSX. They have not made the reason public, but it is widely believed to be due to security concerns. After this point, plugin-based execution times have fallen out of favor and most browsers are removing support for plugins such as Silverlight and Flash. This leaves a hole where the runtime plugins were previously located.

In 2015, WebAssembly was announced for the first time. Wasm’s first demo was with the game Angry Bots which is based on Unity with WebGL. This demo is a fully functional 3D environment inside the browser. Once again, browsers were opened to the use of languages ​​other than JavaScript, and it was still possible to compile code in a modular binary format. Since then, the W3C has put its support behind Wasm, there is a consensus among the four browsers Chrome, Firefox, Safari and Edge that the MVP is complete, and Wasm is now delivered in all new versions of these browsers.

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 run on Wasm. There is currently no C # to Wasm direct compiler. However, the current approach is to compile mono runtime with CIL assemblies in the Wasm bytecode. This allows existing C # code to be executed on Wasm inside the browser. More details can be found in the Github mono-wasm repo.

 

Uno Platform , Avalonia & Blazor

Uno Platform is an ambitious project which aims to provide a platform based on C # / XAML to develop applications that target all platforms. This includes browsers and native iOS / Android. Uno allows developers to define their user interface in the agnostic markup language XAML, which in turn translates to the native user interface architecture of the platform, like the HTML DOM in browsers. This incredible example application is a port from the Windows Community Toolkit. It allows direct XAML editing and linking to manipulate and create user interface elements.

Blazor “allows you to create interactive web user interfaces using C # instead of JavaScript. Blazor applications are made up of reusable web user interface components implemented using C #, HTML and CSS. Client code and server is written in C #, allowing you to share code and libraries. “Blazor offers C # developers a smooth path to convert existing JavaScript applications to C #. This impressive sample allows C # code to be edited and executed in the browser for the Ethereum blockchain with the Nethereum C # library.

In short, these platforms allow C # developers to launch directly and create Web applications with C #. These applications are sandboxed and fast. However, these two technologies render the user interface to HTML components. C # can be used to manipulate components, but rendering is always done by the browser’s built-in engine.

Avalonia is a user interface API based on Microsoft’s WPF UI API. It does not yet support Wasm. However, this technology stands out as a solid candidate for a user interface library that would allow non-HTML DOM rendering inside the browser. This technology can once again make it possible to create and deploy business applications in the browser with perfect pixel rendering. The result should be very similar to Microsoft Silverlight.

This article describes in detail the cross-platform C # interface technologies.

 

Back end and App Development

While browser-based front end development is the obvious use case for C # developers, Wasm won’t stop there. As mentioned on the website, Wasm also targets “web deployment for client and server applications”. This has big implications for C # developers. Wasm is now deployed on almost all devices 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 very likely that Wasm platforms for creating applications outside the browser (non-web integrations) will emerge, and server-side technology will be developed on Wasm. It is also likely that a C # to Wasm compiler will emerge. Wasm can challenge .NET and mono for use. Wasm has a long way to go, but it is possible that we see an ecosystem where modules are built for Wasm and shared between the back-end and the front-end of the systems. This will likely 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 can find themselves in teams where APIs are built simultaneously in different languages.

 

Conclusion

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.

Leave A Comment

Whatsapp Whatsapp Skype