WebAssembly

Introduction to WebAssembly for .NET Developers

Guest Blog Post by Antonii Georgiev I really feel that we are on the brink of a revolution. It’s still very early in the revolution, but I feel like WebAssembly is going to completely change the way we think of web applications. WebAssembly has slowly been stirring up fire since its creation, but why exactly should you be interested in it? Firstly, what is WebAssembly?   WebAssembly operates on a stack-based machine that allows web applications to run near-native speed by using a binary format. It can be generated by higher level programming languages like C++ or C#. The idea is that it runs a lot faster than JavaScript. It’s quite efficient, meaning it’s fast to load and execute. It’s safe and portable just the way JavaScript is. You don’t have to deal with memory overflow exploits and things of that nature. Lastly, it’s portable so it will run in almost any modern browser nowadays. WebAssembly is not intended to kill JavaScript, and it probably won’t. Maybe someday it might replace JavaScript in certain scenarios, altering the way we write our web apps just enough that we may end up writing the majority of our applications in an entirely different

SkiaSharp Support for WebAssembly via Uno Platform

Today we are proud to announce that the Uno Platform now has initial support for SkiaSharp via the Uno.SkiaSharp.Views package which was published to NuGet moments ago. Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms. It serves as the graphics engine for Google Chrome and Chrome OS, Android, Mozilla Firefox and Firefox OS, and many other products. Head on over skiasharp-wasm.platform.uno to see Skia, the Uno Platform and WebAssembly working together using mono’s AOT engine. For the best experience we recommend using a desktop computer and the latest canary version of your favorite browser as the specification is under construction and support for WebAssembly is rapidly improving. You can find the source code for skiasharp-wasm.platform.uno over at unoplatform/Uno.SkiaSharp. Internally this application uses SkiaSharp, a .NET binding to P/Invoke the Skia API and a custom Skia build to provide the C API to allow for the .NET interop. Inside of the Uno.SkiaSharp.Views package you’ll find support for the SKXamlCanvas UWP control which enables drawing using Skia in a specific section of the XAML visual tree. You can experiment with SKXamlCanvas by playing with this sample in our samples repository. Alternatively, you can take it for a spin with the following XAML and Code Behind. XAML:

A Piece of Windows 10 is now running on WebAssembly, Natively on iOS and Android

A few months ago, Microsoft open sourced the Windows Calculator, the very Calculator that ships with Windows 10. We decided to port it to C# and the Uno Platform, so that iOS and Android users could use it, but also use it from the Web using WebAssembly. Why – well that’s what we at Uno Platform do ? – enable the same C# and XAML code to run on the Web, Mobile and Desktop.   You can use it today on: Apple App Store Android Play Store WebAssembly: https://calculator.platform.uno Windows 10 – well, just open it on Windows 10 ? Anatomy of the Windows Calculator The Windows Calculator is an interesting and not-so-simple piece of software. The simple initial UI you see upon launch can be deceiving. Of course, that is a good UX choice Microsoft made as most uses of the calculator are rather simple ones. However, the calculator is complex both in the way it was coded over the years, as well as the advanced functions it has. First, it’s built entirely using standard C++ 11 and C++/CX, with a calculation engine that dates back from 1995. Historically, parts of the C++ code were actually built in C. Second, the calculator contains features such as:

Talkin’ ‘bout my generation: How the Uno Platform generates code, part 1 — Under The hood

In previous articles, we’ve covered how the Uno Platform takes a visual tree defined in the XAML markup language and creates it on iOS, Android, and WebAssembly. In this article I want to dive into a key intermediate step: how the XAML is parsed and mapped to generated C# code. In part 2, we will look at a few other ways in which Uno leverages code generation to make the wheels turn.