WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security...

95
WebAssembly and .NET Joanna Lamch 2019

Transcript of WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security...

Page 1: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly and .NET

Joanna Lamch

2019

Page 2: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Who am I ?Joanna Lamch

[email protected]

Microsoft fangirlDeveloper C#

.NET Framework 1.115 years (+ overtime)XamarinSIENN

CommunityŚląska Grupa MicrosoftWomen In TechnologyGruba.IT

Page 3: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 4: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Back in the days…

Page 5: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

1991

Page 6: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Hypertext, HTML, HTTP

ypertext" is also used to describe tables, images, and other content formats with integrated hyperlinks. Hypertext

Hypertext documents are interconnected by hyperlinks, which are activated by a mouseClick, keypress set or by touching the screen

Page 7: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

created in 10 days in May 1995, by Brendan Eich for Netscape

Adding interactivity to HTML pages

1995

JavaScript

Page 8: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

1995

JavaScript

Page 9: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

JavaScript

1995

Page 10: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Java Applets [1997]

ActiveX [1996]

Flash [1996]

Silverlight [2007]

Other plugins

1996+

Page 11: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Java Applets [1997]

ActiveX [1996]

Flash [1996]

Silverlight [2007]

All of them are deprecated

or will be deprecated soon

Other plugins

1996+

Page 12: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Browser performance wars (2008+)

Page 13: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Browser performance wars (2008+)

Page 14: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Browser performance wars (2008+)

https://blog.mozilla.org/luke/2014/01/14/asm-js-aot-compilation-and-startup-performance/

ASM.js

OdinMonkey

Page 15: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Browser performance wars (2008+)

Page 16: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Different way the same language

there is a LOT of JavaScript

Todays JavaScript

JavaScript is the language of the Web

But it’s not very good Assembly Language(still human readable simple language)

Page 17: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Todays JavaScript

Page 18: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly What? Why?

A new low-level binary format for the web (WASM)

It’s a bytecode for web / compilation target => maximized performance

Page 19: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly What? Why?

Sandboxed runtime in JS virtual machineSecurity it runs locally in JS VM

WebAssembly is not designed to replace JS, but to coexist

A new low-level binary format for the web (WASM)

It’s a bytecode for web / compilation target => maximized performance

Page 20: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly What? Why?

Sandboxed runtime in JS virtual machineSecurity it runs locally in JS VM

Supported in all big browsers –W3C open specification

WebAssembly is not designed to replace JS, but to coexist

A new low-level binary format for the web (WASM)

It’s a bytecode for web / compilation target => maximized performance

Page 21: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly What? Why?

Compiled from other languages

Sandboxed runtime in JS virtual machineSecurity it runs locally in JS VM

Supported in all big browsers –W3C open specification

WebAssembly is not designed to replace JS, but to coexist

A new low-level binary format for the web (WASM)

It’s a bytecode for web / compilation target maximized performance

Page 22: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WASM opens possibilities for other languages

Page 23: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WASM opens possibilities for other languages

Page 24: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WASM opens possibilities for other languages

Page 25: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• Compilation target

Binary so compact

• 4 types, 67 instructions, stack machine

WebAssembly current state: MVP

• Linear memory

• Fast execution

Page 26: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• Compilation target

Binary so compact

• 4 types, 67 instructions, stack machine

• Linear memory

• Fast execution

• No Web APIs, DOMaccess/manipulation

•or not so fastnot so fast load

• no Threads

WebAssembly current state: MVP

Page 27: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly How?

executes the Emscripten compiler name our output file

Emscripten outputs WebAssembly - switch input file

$emcc –s WASM=1 -o example.js example.cpp

Page 28: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WebAssembly studio C/Rust/TypeScript

https://hacks.mozilla.org/2018/04/sneak-peek-at-webassembly-studio/

Page 29: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

http://mbebenita.github.io/WasmExplorer/

https://wasdk.github.io/WasmFiddle/

https://webassembly.studio/

Demo

Page 30: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WasmExplorer

https://bit.ly/2JkqFYt

Page 31: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WasmExplorer

https://bit.ly/2JkqFYt

Page 32: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 33: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 34: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 35: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 36: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 37: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Figma

https://www.figma.com

https://www.youtube.com/watch?v=Kf1gILChfks

WASM in real world

Page 38: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

WASM in real world

http://through-the-interface.typepad.com/through_the_interface/2018/03/the-future-of-autocad.html

Page 39: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 40: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

http://www.continuation-labs.com/projects/d3wasm/?fbclid=IwAR2V9OqEDgu3bu-vMNlxcZCUOm0HQAlv6ys-jcZGSMQY56saD8FYrHdVx_s

Page 41: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/win2k.cfg&mem=192&graphic=1&w=1024&h=768

Page 42: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

http://assets.metacade.com/emulators/win311vr.html?fbclid=IwAR11_ewC5oIgxnF8esrmlqDCTnn99jQZVLlkVdQyGQhFZePgRaIH-X4ef4g

Page 43: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• WASM in real world

Figmahttps://www.figma.com/

https://www.youtube.com/watch?v=Kf1gILChfks

https://s3.amazonaws.com/mozilla-

games/ZenGarden/EpicZenGarden.html?fbclid=IwAR0_uAensGfTj1Mzp4wXgVoxZjquxRo_uu2YD8yDuleTpPohaXyilDd82X8

https://bellard.org/jslinux/vm.html?url=https://bellard.org/jslinux/win2k.cfg&mem=192&graphic=1&w=1024&h=768

https://aesalazar.github.io/AsteroidsWasm/

http://sqliteefcore-wasm.platform.uno/

https://raytracer-mono-aot.platform.uno/

http://www.continuation-labs.com/projects/d3wasm/?fbclid=IwAR2V9OqEDgu3bu-vMNlxcZCUOm0HQAlv6ys-

jcZGSMQY56saD8FYrHdVx_s

http://assets.metacade.com/emulators/win311vr.html?fbclid=IwAR11_ewC5oIgxnF8esrmlqDCTnn99jQZVLlk

VdQyGQhFZePgRaIH-X4ef4g

Page 44: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 45: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Stable, mature, productive: .NET Standard, MSBuild

Fast, scalable, reliable: .NET Core for backend services

Modern languages: Innovations in C#, F#, Razor

First-rate dev tools: Visual Studio, IntelliSense

Solid foundation to build on

Leverage existing skills and knowledge

Because We can

Why use .NET for browser apps?

.NET

Page 46: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

C# in wasm ? Mono !

https://github.com/migueldeicaza/mono-wasmhttps://www.mono-project.com/news/2018/09/11/csharp-jit/https://twitter.com/migueldeicaza/status/1039639597435641856

Page 47: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Interpreter mode vs AOT compiled

Page 48: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

XAML standard is ready

XAML for desktop app

Page 49: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

XAML standard is ready and dead

XAML for desktop app

Page 50: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

XAML standard is ready and dead

• Xamarin.Forms

• UWP

• Silverlight

• WPF

XAML for desktop app

Page 51: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Ooui

C# Platform Specific C# Platform Specific C# Platform Specific

iOS Renderers Android Renderers Windows Renderers

Shared C# App Logic

(ViewModels, Models etc.)

Mono .NET

DLLs(external packages & libraries)

Shared C# UI Code(Xamarin.Forms XAML)

Web Platform Specific

Web Renderers

Page 52: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

UNO

Page 53: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

FrogUI

https://www.lesarde.com/

Page 54: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor? Razor components ?

Page 55: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor

https://github.com/aspnet/AspNetCore/issues/8931

Page 56: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

UI thread

Blazor

Blazor client-side

.cs

.cshtml

BROWSER

WebAssembly(mono.wasm)

.NET(mscorlib.dll, System.Core.dll,…)

App.dllCompile to .NET

assemblies

Page 57: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Razor Component razorcomponent [C#] Web/ASP.NET

Razor Page page [C#] Web/ASP.NET

MVC ViewImports viewimports [C#] Web/ASP.NET

MVC ViewStart viewstart [C#] Web/ASP.NET

Blazor (server-side) blazorserverside [C#] Web/Blazor

Blazor (ASP.NET Core hosted) blazorhosted [C#] Web/Blazor/Hosted

Blazor Library blazorlib [C#] Web/Blazor/Library

Blazor (client-side) blazor [C#] Web/Blazor/Standalone

ASP.NET Core Empty web [C#], F# Web/Empty

ASP.NET Core Web API webapi [C#], F# Web/WebAPI

Razor Class Library razorclasslib [C#] Web/Razor/Library/Razor Class Library

Blazor new project

Page 58: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor client-side

C:\Projects> dotnet new blazor -n JLBlazorExample

Page 59: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor client

C:\Projects> dotnet new blazor

Page 60: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 61: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" /><p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor: SampleBlazor:

Page 62: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: Routing

@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" /><p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor:

Page 63: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: Razor template

@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" />

<p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor:

Page 64: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: C#@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" /><p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor:

Page 65: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: One way data binding@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" />

<p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {

int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor:

Page 66: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: Two way data binding@page "/counter"@inject HttpClient

<h1>Counter</h1>

<input type="number" bind="IncrementAmount" />

<p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;

int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor:

Page 67: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

@page "/counter"@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" /><p>Current count: @currentCount</p>

<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor: Event bindingBlazor:

Page 68: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

@page "/counter"

@inject HttpClient

<h1>Counter</h1><input type="number" bind="IncrementAmount" /><p>Current count: @currentCount</p><button class="btn btn-primary" onclick="@IncrementCount">Click me</button>

@functions {int currentCount = 0;int IncrementAmount { get; set; } = 1;

void IncrementCount(){

currentCount += IncrementAmount;}

}

Blazor: UsingBlazor:

Page 69: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

JavaScript interop

Page 70: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

BrowserB

WASM + C#

Page 71: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor sample in browser

Page 72: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 73: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 74: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 75: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 76: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification
Page 77: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Browser

UI Thread

Let’s switch elements places

Server

dotnet

SignalRJavaScriptBlazor

ComponentsBlazor

Page 78: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor server-side

JavaScript

Page 79: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor server-side

C:\Projects> dotnet new blazorserverside -n JLBlazorServerSide

Page 80: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazorserver-side

Page 81: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazorserver-side

Page 82: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

public class Program { //Blazor client side

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>

BlazorWebAssemblyHost.CreateDefaultBuilder().UseBlazorStartup<Startup>();

}

public class Program { //Blazor server side

public static IHostBuilder CreateHostBuilder(string[] args) =>

Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(webBuilder =>

{webBuilder.UseStartup<Startup>();});

}

public class Startup {

public void ConfigureServices(IServiceCollection services) {

services.AddRazorPages();

services.AddServerSideBlazor();

services.AddSingleton<WeatherForecastService>();

}

Page 83: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

UI component ecosystem

Page 84: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Blazor: possibilities

https://www.youtube.com/watch?v=qrf3OrLHeFISteve Sanderson - Blazor, a New .NET Single Page Application Framework | Øredev 2018

Page 85: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

What’s the future?

Page 86: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Loadtime improvements

• streaming compilation• tiered compilation• implicit HTTP caching• other improvements

Making useof modern Hardware• threading• SIMD• wasm 64bit

https://github.com/WebAssembly/design/blob/master/FutureFeatures.md

What WebAssembly are next to?

Page 87: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• fast callsJS <~> wasm

• esy and fastdata exchange

• ES module integration

• toolchain integrationlike npm or webpack

• backward compatibility

What WebAssembly are next to?

Page 88: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Hight level language features

• GC integration

• Exception handling

• Debugging

• Tail cals

What WebAssembly are next to?

Page 89: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Security Portability

WASI – WebAssembly System Interface

Page 90: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

CloudFlare

https://blog.cloudflare.com/cloud-computing-without-containers/https://www.youtube.com/watch?v=A9SydP1CcZU

Page 91: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

CloudFlare no more cold starts?

Page 92: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

Possibilities

FlexibilityDiversity

Cross-platform

Promise of bright tomorrow for todays projects

So WebAssembly?

Page 93: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

THANK YOU

Questions?? Joanna [email protected]

JLamch.net

ProgramistkaIKot.pl

Page 94: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• Ankieta

• Będzie mi miło móc ulepszyć moją prezentację dzięki Twoim komentarzom, dlatego proszę Cię o wypełnienie ankiety, bądź kontakt mailowy.

Działanie pociąga za sobą koszty i ryzyko, ale o wiele mniejsze niż te, które wiążą się z wygodną bezczynnością

Page 95: WebAssembly and · Compiled from other languages Sandboxed runtime in JS virtual machine Security it runs locally in JS VM Supported in all big browsers –W3C open specification

• Bibliografia

• https://webassembly.org/docs/high-level-goals/

• https://www.smashingmagazine.com/2017/05/abridged-cartoon-introduction-webassembly/

• https://www.youtube.com/watch?v=HktWin_LPf4&feature=youtu.be

• https://www.youtube.com/watch?v=pBYqen3B2gc

• https://www.youtube.com/watch?v=BnYq7JapeDAhttps://www.youtube.com/watch?v=kS29TT4wk44&feature=youtu.be

• https://github.com/mbasso/awesome-wasm

• https://github.com/migueldeicaza/mono-wasm

• https://superkotlin.com/kotlin-and-webassembly/

• https://medium.com/@mumarov/how-to-get-started-with-kotlin-native-and-web-assembly-baa2813f0d9

• https://github.com/DenisKolodin/yew

• https://www.mergeconflict.fm/89• https://dotnetrocks.com/?show=1539• https://dotnetrocks.com/?show=1540• https://dotnetrocks.com/?show=1537

• https://www.hanselman.com/blog/NETAndWebAssemblyIsThisTheFutureOfTheFrontend.aspxhttps://hacks.mozilla.org/2018/04/sneak-peek-at-webassembly-studio/

• https://github.com/migueldeicaza/mono-wasm?WT.mc_id=-blog-scottha

• https://blog.scottlogic.com/ceberhardt/

• https://blog.logrocket.com/working-with-the-blazor-javascript-interop-3c2a8d0eb56chttps://s3.amazonaws.com/mozilla-games/ZenGarden/EpicZenGarden.htmlhttps://blog.logrocket.com/working-with-the-blazor-javascript-interop-3c2a8d0eb56c