News

Edge Browser Switches WebAssembly to 'On'

For the first time, the Microsoft Edge Web browser provides out-of-the-box support for WebAssembly, the experimental technology that lets developers write Web code in non-JavaScript languages like C, C++ and even -- with a little work -- .NET languages like C#.

This new functionality comes in the updated Microsoft Edge version called EdgeHTML 16 -- and its Chakra JavaScript engine -- that ships with the Windows 10 Fall Creators Update being rolled out worldwide.

EdgeHTML and Chakra previously supported the experimental WebAssembly with an initial effort called WebAssembly Minimum Viable Product (MVP), kind of a proof of concept that lacks various important features.

Along with other new features -- SharedArrayBuffer and support for Atomics -- the MVP WebAssembly functionality was disabled by default with an "Experimental JavaScript Features" flag.

In the latest iteration of EdgeHTML 16, those features have been fine-tuned, stabilized and enabled by default, buttressed by many tweaks that have improved performance.

Just about 2-1/2 years since it was first announced, WebAssembly might not be familiar to some Web jockeys. Developers don't write code in the WebAssembly binary bytecode format ("wasm" files), but rather they can write in other languages that are compiled into WebAssembly.

Although WebAssembly in certain implementations can reportedly relieve Web developers from "the insanity of JavaScript," it's tightly intertwined with the ubiquitous Web language and has been described as being evolved from JavaScript or even being a subset of JavaScript.

As a primary backer of the project -- the Mozilla Developer Network (MDN) around the Firefox Web browser -- puts it:

WebAssembly is a new type of code that can be run in modern Web browsers -- it is a low-level assembly-like language with a compact binary format that runs with near-native performance and provides languages such as C/C++ with a compilation target so that they can run on the Web. It is also designed to run alongside JavaScript, allowing both to work together.

Mozilla and other browser makers are helping to shepherd the new technology approach as an open standard under a W3C Community Group.

While WebAssembly may have been flying under the radar in some mainstream Web development circles, it promises radical implications for the traditionally JavaScript/HTML/CSS-dominated space.

Putting it bluntly, Mozilla developer David Bryant said: "WebAssembly is one of the biggest advances to the Web Platform over the past decade."

And that carries over into the .NET ecosystem too, though it takes a bit more work to leverage WebAssembly in languages such as C#.

C# Code for the Web
[Click on image for larger view.] C# Code for the Web (source: Scott Hanselman).

Cautioning that "this is just an experiment," Microsoft developer Steven Sanderson this summer posted a YouTube video on WebAssembly and other new technologies titled "Web Apps can't really do *that*, can they?" Commenting on one part of the video that used C code, one developer on Reddit noted: "The big browsers are really working on integration of other languages and debugging of them live in the browser. No mapping for C# code though, since the C# code is not compiled directly to webassembly, but interpreted by the small dotnetanywhere runtime."

Sanderson was able to write the traditional JavaScript Todo app with C#, however.

There are also other efforts underway to wed .NET and WebAssembly, as Microsoft's Scott Hanselman pointed out in an August post titled ".NET and WebAssembly -- Is this the future of the front-end?" in which he noted: "Today in 2017, WebAssembly is absolutely a thing."

Hanselman reported on Sanderson's presentation and detailed some of these other efforts, including the WebAssembly for .NET project and the mono-wasm project. The former is intended to "to consume WASM binary files and execute them from within .NET assemblies" while the latter is described as "a proof-of-concept aiming at building C# applications into WebAssembly, by using Mono and compiling/linking everything statically into one .wasm file that can be easily delivered to browsers." Mono, of course, is the open source runtime that was turned into Xamarin.

"We have been experimenting with a couple of approaches to bring Mono to the Web using WebAssembly -- a technology that can efficiently and safely execute code in Web browsers without being limited to JavaScript," said Mono/Xamarin chief Miguel de Icaza in an August blog post. "Running code written in C or C++ inside the browser has been a big motivator, but most major programming languages have plans to target WebAssembly as a platform."

Meanwhile, the EdgeHTML team will continue work to support WebAssembly. Already, the aforementioned tweaks to the initial MVP offering have paid off in better performance. "Several changes also help improve WebAssembly performance in Chakra by 20-25 percent on workloads we have been tracking," said Limin Zhu, a Microsoft program manager, in a blog post last week . "Try it out for yourself! Point Microsoft Edge at a fun WebAssembly game like Funky Karts to see the improvement with no flags required!"

Zhu said Microsoft will continue its close work with Mozilla, Google, Apple and other WebAssembly backers to improve the initiative. "Impactful post-MVP features such as threads and GC [garbage collection] are currently being explored in the WebAssembly Community Group," he said.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube