.NET in the browser: Cross-platform Single Page Applications with WebAssembly & ASP.NET Blazor - erm, really?
Very early data about and views on WebAssembly and ASP.NET Blazor for running native code and .NET-based SPAs in the browser.
*Very experimental technologies*
on § Mobile & web-based application architectures § Pragmatic end-to-end solutions § Cloud-native architectures § Microsoft MVP for ASP.NET (Architecture) ASPInsider, AzureInsider § Google GDE for Web Technologies § [email protected] § ! @christianweyer § Consultant & Architect at Thintecture AG § Focus on § Flexible and scalable backend architectures § Developer productivity § Software Quality measures § All things .NET § [email protected] § ! @phoenixhawk Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor .NET im Browser Christian Weyer Sebastian Gingter
Page Applications § WebAssembly as a native bytecode for the Web § ASP.NET Blazor: an experimental project for .NET-based SPAs § Q&A Topics .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
for users § Windows, Linux, macOS, Android, iOS: a mixture of everything, anywhere § Desktop is still important, not everything is mobile § Software developers need to care about & target ubiquitous systems § Depending on the actual audience, on the actual use cases § The web has proven to be a universal platform Modern Business Applications .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
clients § JavaScript is the language for the web § Various SPA frameworks have conquered the world in the past years § AngularJS § React § Angular § Vue.js § Etc. § Strongly-typed languages like TypeScript make lives of .NET developers a lot easier Modern Business Applications & the Web .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
for some application endeavours § Sharing code/logic for more complex scenarios is not easy for .NET- based backends § Using existing special purpose libraries written in any language is not possible § Seeking superior performance for some use cases § Some developers really want to get rid of JavaScript ! “Houston, we have some problems” .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
as a low-level, efficient target language for compilers § Effectively describes a sandboxed virtual machine for memory-unsafe languages like C or C++ § Combination of static and dynamic validation allows JavaScript engines to employ an ahead-of-time (AOT) optimizing compilation strategy for valid asm.js code § But it is not enough, yet § https://brendaneich.com/2015/06/from-asm-js-to-webassembly/ Still JavaScript: asm.js .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
§ Because JavaScript ! (but not a replacement for JavaScript!) § Bring any language into the browser § Superior performance § Goals § Fast, efficient, portable § Readable and debuggable § Use existing sandboxing tools § Don’t break the web § Binary (.wasm) & text (.wat) format § Officially open source § http://webassembly.github.io/spec/core/index.html Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor .NET im Browser WebAssembly (WASM)
frame in WebAssembly, UI in JavaScript / HTML / CSS § Re-use existing code by targeting WebAssembly, embedded in larger JavaScript / HTML application § Anything from simple helper libraries, to compute-oriented task offload Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor .NET im Browser WASM-based Applications
toolchain infrastructure library for WebAssembly, written in C++ § LLVM. The modern C/C++ compiler toolchain § Emscripten: LLVM-to-JavaScript-or-WASM compiler § Tools cross-compiling from major languages § mono-wasm from C# § Cheerp from C++ § TeaVM from Java § Rust § WebAssembly Studio: playing around with WASM in the browser WASM Tooling .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor https://developer.mozilla.org/en-US/docs/WebAssembly/Concepts
§ Xamarin is based on Mono § Support .NET Standard § Mono team is working on tooling to compile Mono/.NET code to WASM § mono-wasm § JIT § AOT Mono & WASM .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor http://www.mono-project.com/news/2018/01/16/mono-static-webassembly-compilation/
on new features § Threads § Garbage Collection § Direct DOM access § Many more things… § See https://github.com/WebAssembly/design/blob/master/FutureFeatures.md WASM: Here & to Stay .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
framework for .NET § … and it changes every day § Blazor projects run 100% in the browser § On top of a WASM build of the Mono .NET runtime § Compiled .NET assemblies are loaded into the browser and JIT compiled § Uses Razor / .cshtml templates for rendering HTML / CSS § Uses C# for writing application logic What is ASP.NET Blazor? .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
(yet?) suitable for real-world applications § It is NOT a way to port Razor / MVC / server-side web applications to a SPA § It is NOT a way to bring XAML/WPF/Xamarin into the browser What is ASP.NET Blazor NOT? .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor
Studio 15.7.0 Preview § Blazor Language Service from Visual Studio Marketplace ASP.NET Blazor prerequisites (as of today*) .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor * Today: April 23, 2018
need to know HTML, CSS and JavaScript. Period. § WebAssembly § Brings any programming language and sandbox-aware framework to the browser § May pave the way to write business applications entirely without JavaScript – some day… § ASP.NET Blazor § Experimental SPA Framework § Very early stages § Shows possibilities of WebAssembly with .NET § *Do not use in production* Summary .NET im Browser Cross-Plattform Single Page Applications mit WebAssembly & ASP.NET Blazor