Skip to content

WebAssembly

Kota edited this page Sep 25, 2018 · 2 revisions
  • A code (binary code format, .wasm extension) that can be run in modern web browsers and provides new features and major gains in performance
  • .wat format, human readable format of .wasm
  • Started in 2015. Standardized by W3C group
  • Web assembly gets executed by the javascript runtime (vm) on the browser
  • JS should be understood by runtime whereas wasm is written in runtime understandable format, so faster
  • Web assembly can also run on other places than in web browser

Why

  • Run code at near-native speed. 6-20 times faster than JavaScript (scenario based)
    • byte code (lower level language) so smaller in size
  • Other languages can be compiled to WebAssembly. Like C++, C#, Razor, Java etc..
  • Natively supported by all major browsers (doesn't require plugins)
  • Secure: Runs in the java-script sandbox
  • JavaScript code can run WebAssembly modules
  • Since it is browser based, it works on all devices desktop, mobile, tablet, virtual device etc..

Why not

  • Javascript has lot of benefits and are faster enough for normal operations.
  • Javascript is Human readable
  • Not supported by IE

Uses

  • Video / Audio editing
  • Video / Audio streaming
  • Gaming
  • Video / Audio Calling
  • Virtual / Augmented reality
  • AI on client. Ex: Image recognition

How to do?

  • Compile C# to dll -> the dll runs on the mono runtime (Mono.wasm), which is converted into webassembly and runs on webassembly runtime => Microsoft Blazor Toolchain
  • Create ASP.NET Core web Application -> Blazor template -> OK
  • Javascript loads the wasm file and runs it. Also, wasm can call Javascript code

Links:

Resources:

Clone this wiki locally