Slide 1

Slide 1 text

Wie .NET jetzt auch den Browser erobert?

Slide 2

Slide 2 text

Special Day Modern Business Applications Thema Sprecher Datum, Uhrzeit Raum Pragmatische Microservices-Architekturen mit ASP.NET Core Web APIs, SignalR & Co. Christian Weyer DI, 25. September 2018, 10.30 bis 11.30 Gutenberg 2+3 Serverless-Architekturen: Event-basierte Microservices mit Azure Functions & Co. Christian Weyer DI, 25. September 2018, 11.45 bis 12.45 Gutenberg 2+3 Angular: Komponentenorientierte Web- Anwendungen Christian Liebel DI, 25. September 2018, 14.15 bis 15.15 Zagreb B Progressive Web Apps: Next Step for Web-based Cross- Platform Applications Shmuela Jacobs DI, 25. September 2018, 16.00 bis 17.00 Zagreb B WebAssembly und Blazor: Wie .NET jetzt auch den Browser erobert? Sebastian Gingter, Christian Liebel DI, 25. September 2018, 17.15 bis 18.15 Gutenberg 1

Slide 3

Slide 3 text

− Glimpse into the future of application development − Seeing the web in action as the platform − “Native” programming languages running in your browser − Sneak Peek: Single-Page Applications with .NET − Demos − WebAssembly/mono-wasm/ Blazor Deep Dive − Future-proof tutorial (WebAssembly is stable, but mono-wasm/Blazor aren’t) − Flash, Silverlight, Java Applets Wie .NET jetzt auch den Browser erobert?

Slide 4

Slide 4 text

▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ Wie .NET jetzt auch den Browser erobert? ▪ ▪ ▪ ▪ 4

Slide 5

Slide 5 text

1. Modern Business Applications & the Web 2. WebAssembly: Native Bytecode for the Web 3. Mono & WebAssembly: .NET Comes to the Browser 4. Blazor: Single-Page Apps Come to C# Wie .NET jetzt auch den Browser erobert?

Slide 6

Slide 6 text

Wie .NET jetzt auch den Browser erobert?

Slide 7

Slide 7 text

Frontend Technologies • HTML5 • CSS • JavaScript Modern Web APIs • WebAssembly • Web Audio API • Gamepad API • Media Capture and Streams • Web Bluetooth API Single-Page Web Applications • Angular • React • Vue Backend Technologies • .NET Core • Node.js Wie .NET jetzt auch den Browser erobert?

Slide 8

Slide 8 text

Wie .NET jetzt auch den Browser erobert?

Slide 9

Slide 9 text

− Native operating systems & platforms get less important 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 browsers are power horses – more or less like an operating system Wie .NET jetzt auch den Browser erobert?

Slide 10

Slide 10 text

Wie .NET jetzt auch den Browser erobert? Compiler Parser JIT Web APIs (DOM, IndexedDB, File Storage etc.) Browser JavaScript (.js) HTML (.html) Inline JS JS Runtime

Slide 11

Slide 11 text

Wie .NET jetzt auch den Browser erobert? The Web is too… Web-ish The web is centered around a single language

Slide 12

Slide 12 text

Native Bytecode for the Web Wie .NET jetzt auch den Browser erobert?

Slide 13

Slide 13 text

− Low-Level Bytecode for the Web − High execution speed − Fast, efficient, portable − Readable and debuggable − Uses existing sandboxing tools − Part of the open, backwards- compatible web Wie .NET jetzt auch den Browser erobert?

Slide 14

Slide 14 text

Wie .NET jetzt auch den Browser erobert?

Slide 15

Slide 15 text

− Implemented in all major browsers (2017+) − Evergreen browsers (Chrome 57, Edge 16, Firefox 52 (not in ESR), Safari 11) − Desktop and mobile − Native technology (i.e. no plug-ins!) − Idea: Bring all programming languages to the browser − Targeted at languages such as C, C++ or Rust (= languages without garbage collection) − Achieves superior performance for some use cases − Addition to JavaScript (not a replacement!) − JavaScript glue code is still required to load a WebAssembly − Currently, JavaScript counterpart is required for accessing the DOM Wie .NET jetzt auch den Browser erobert?

Slide 16

Slide 16 text

− After v1 (the MVP), the consortium keeps working on new features − Threads − Garbage Collection − Reference Types − Direct DOM access − Many more things… − https://github.com/WebAssembly/design/blob/master/FutureFeatures.md − BTW: WASM also works on the server − e.g. WASM loader for Node.js − https://github.com/wasm-tool/node-loader Wie .NET jetzt auch den Browser erobert?

Slide 17

Slide 17 text

Wie .NET jetzt auch den Browser erobert? https://blogs.windows.com/msedgedev/2018/06/19/improved-javascript- webassembly-performance-edgehtml-17/ https://hacks.mozilla.org/2018/01/making-webassembly-even-faster-firefoxs-new-streaming-and-tiering-compiler/

Slide 18

Slide 18 text

Wie .NET jetzt auch den Browser erobert? Compiler Parser JIT Web APIs (DOM, IndexedDb, File Storage etc.) Browser JavaScript (.js) HTML (.html) Inline JS JS Runtime WebAssembly (.wasm)

Slide 19

Slide 19 text

− Re-use existing code by targeting WebAssembly, embedded in larger JavaScript/HTML application − Anything from simple helper libraries, to compute-oriented task offload − Main application frame & logic in WebAssembly, UI in JavaScript/ HTML/CSS − Entire code base in WebAssembly Wie .NET jetzt auch den Browser erobert?

Slide 20

Slide 20 text

Wie .NET jetzt auch den Browser erobert? Binary (.wasm) & text (.wat) format

Slide 21

Slide 21 text

− Baremetal: WebAssembly Studio − Playing around with WASM in the browser − C/C++ tools & compilers − Binaryen: compiler and 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 − Cheerp (from C++) − TeaVM (from Java) − Rust − mono-wasm (from C#) Wie .NET jetzt auch den Browser erobert? C / C++ Source code .wasm module HTML doc JS glue code Emscripten +

Slide 22

Slide 22 text

WebAssembly Studio https://webassembly.studio/ Wie .NET jetzt auch den Browser erobert? LIVE DEMO

Slide 23

Slide 23 text

.NET Comes to the Browser Wie .NET jetzt auch den Browser erobert?

Slide 24

Slide 24 text

− Mono is Microsoft’s strategy for cross-platform client applications − Xamarin is based on Mono, Unity as well − Support for .NET Standard − Mono team is working on tooling to compile Mono/.NET code to WASM − Two approaches − JIT – for fast development cycles, including live reload (part of mono-master) − AOT – for optimized runtime deployment & execution (aka mono-wasm) Wie .NET jetzt auch den Browser erobert?

Slide 25

Slide 25 text

Wie .NET jetzt auch den Browser erobert? $ mcs -nostdlib -noconfig -r:../../dist/lib/mscorlib.dll hello.cs - out:hello.exe $ mono-wasm -i hello.exe -o output $ cp index.html output $ ls output hello.exe index.html index.js index.wasm mscorlib.dll

Slide 26

Slide 26 text

using System; public class Hello { public static void Main(string[] args) { Yell("Hack"); } public static void Yell(string text) { Console.WriteLine($"{text.ToUpperInvariant()}!!!"); } } Wie .NET jetzt auch den Browser erobert?

Slide 27

Slide 27 text

document.addEventListener('WebAssemblyContentLoaded', () => { const klass = MonoClass('', 'Hello'); const method = MonoMethod(klass, 'Yell', true); MonoInvoke(0, method, ['Hallo']); }); Wie .NET jetzt auch den Browser erobert?

Slide 28

Slide 28 text

Wie .NET jetzt auch den Browser erobert?

Slide 29

Slide 29 text

mono-wasm https://github.com/lrz/mono-wasm Wie .NET jetzt auch den Browser erobert?

Slide 30

Slide 30 text

Single-Page Apps Come to C# Wie .NET jetzt auch den Browser erobert?

Slide 31

Slide 31 text

− Blazor is an experimental Single Page Application (SPA) framework based on .NET − 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 Wie .NET jetzt auch den Browser erobert? * as of June 19, 2018

Slide 32

Slide 32 text

https://blazor.net/docs/get-started.html dotnet new -i Microsoft.AspNetCore.Blazor.Templates dotnet new blazor -o BlazorApp1 cd BlazorApp1 dotnet run Wie .NET jetzt auch den Browser erobert? LIVE DEMO

Slide 33

Slide 33 text

Wie .NET jetzt auch den Browser erobert?

Slide 34

Slide 34 text

Wie .NET jetzt auch den Browser erobert? Compiler Parser JIT Web APIs (DOM, IndexedDb, File Storage etc.) Browser blazor.js Blazor page (.html) JS Runtime mono.wasm mono.js mscorlib.dll etc. myapp.dll * as of September 25, 2018

Slide 35

Slide 35 text

− It is NOT about running any .NET Code just in the browser − We still have a sandbox − Various .NET Standard APIs will just not work in the browser − It is NOT a way to port Razor/MVC/server-side web applications to an SPA − It is NOT a way to bring XAML/WPF/Xamarin into the browser − You may want to look at the Ooui.WASM open source project for this − It is NOT production-ready − Therefore, it is NOT suitable for real-world applications (yet?) Wie .NET jetzt auch den Browser erobert?

Slide 36

Slide 36 text

Tanks! WebAssembly Demo https://webassembly.org/demo/Tanks/ Wie .NET jetzt auch den Browser erobert? LIVE DEMO

Slide 37

Slide 37 text

Sun Temple – Unreal Demo http://s3.amazonaws.com/mozilla-games/tmp/2017-02-21- SunTemple/SunTemple.html Wie .NET jetzt auch den Browser erobert? LIVE DEMO

Slide 38

Slide 38 text

− The Web is still the Web − You need to know HTML, CSS and JavaScript. Period. − Progressive Web Apps − Emerging technologies enable more app-like feeling and behaviors of Web apps – including offline − WebAssembly − Brings any programming language and sandbox-aware framework to the browser − May pave the way to write business applications without large JavaScript parts – some day… maybe − Blazor − Experimental SPA Framework by the ASP.NET Core team, very early stages – do not use in production − Shows possibilities of WebAssembly with .NET/possible future UI framework? Wie .NET jetzt auch den Browser erobert?

Slide 39

Slide 39 text

Windows 3.11 in the Browser https://classicreload.com/win3x-windows-311.html Wie .NET jetzt auch den Browser erobert? LIVE DEMO

Slide 40

Slide 40 text

No content