What is WebAssembly?
Tags: wasi, webassembly, rust, c
Published: 2020-05-02 00:14:15

![webassembly black and white logo](https://www.w3.org/comm/assets/logos/web-assembly-logo-black-150px.png)
WebAssembly aka wasm යනු JavaScript හැර වෙනත් programming languages වලින් ලියලා තියෙන code call/import කරන්න හා browser ඇතුලේ ඒ code run කරන්න හදපු විදිය. ඉතිං JavaScript එක්ක බැලුවහම wasm වේගවත්. Mozilla research වැඩ කරන Luke Wagner කියන මහත්තයා 2015 දී තමයි මුලින්ම WebAssembly කියනදේ ලෝකෙට හදුන්වා දෙන්නේ.

2019 දෙසැම්බර් 5 - World Wide Web Consortium (W3C) නිවේදනය කලා Browser run කරන්න ඉඩ දෙන හතරවෙනි භාෂාව විදියට WebAssembly. ඉතිං Developers ලා එකම application WebAssembly සහ JavaScript යන දෙකම පාවිච්චි කරාවි. හරියට නිකං CSS import කරලා පාවිච්චි කරනවා වගේ.

![Load encrypted model data with WebAssembly and Rust | Autodesk Forge](https://flint-prodcms-forge.s3.amazonaws.com/prod/s3fs-public/inline-images/29D1AE11-D43C-4BAB-AD42-87EFBD38E36B.jpeg)
## How does it work?

![](https://research.mozilla.org/files/2018/03/2018.02.22.WASM-diagram1-600x290.png)
C/C++ හෝ Rust code, wasm වලට compile කරලා JavaScript app load කරලා වැඩ කරගන්න පුලුවම්.

![A wasm file with arrows pointing to and from: logos for different runtimes (Ruby, php, and Python), other wasm files compiled from Rust and Go, and host systems like the OS or browser](https://2r4s9p1yi1fa2jd7j43zph8r-wpengine.netdna-ssl.com/files/2019/08/01-03-star-diagram-500x394.png)
## Compiling to .wasm

-   C/C++ - LLVM වල `clang` front-end / Emscripten `emcc`
-   Rust - Cargo වල `wasm-pack` package

![Diagram of the compiler toolchain](https://2r4s9p1yi1fa2jd7j43zph8r-wpengine.netdna-ssl.com/files/2017/02/04-03-toolchain07-500x411.png)
![https://i.postimg.cc/RhF1VZ1m/Untitled0.png](https://i.postimg.cc/RhF1VZ1m/Untitled0.png)
## WASI - WebAssembly Interface Types

![WASI |](https://wasi.dev/polyfill/WASI-small.png)
Browser පිටත WebAssembly run කරන්න පුලුවම් වෙන්න ඕනි.

WebAssembly තමන්ගේම standalone runtime run විතරක් නෙමෙයි. Python, Ruby, and Rust languages වලිනුත් WebAssembly run ඕනි.

එහෙම කරන්න ඕනි ඇයි?

-   “native” modules වල සංකිරණ තාවය අඩු කරන්න
-   Native code sandbox කරීම පහසු කරන්න
-   Platforms අතර native code share කරන්න

![Diagram showing WebAssembly interface types in the middle. On the left is a wasm module, which could be compiled from Rust, Go, C, etc. Arrows point from these options to the types in the middle. On the right are host languages like JS, Python, and Ruby; host platforms like .NET, Node, and operating systems, and more wasm modules. Arrows point from these options to the types in the middle.](https://2r4s9p1yi1fa2jd7j43zph8r-wpengine.netdna-ssl.com/files/2019/08/04-06-types-as-IR-500x321.png)

>> Don't forget to say hello to the search box for further details.

---

## References

https://www.w3.org/2019/12/pressrelease-wasm-rec.html.en
https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/
https://hacks.mozilla.org/2017/02/creating-and-working-with-webassembly-modules/
https://research.mozilla.org/webassembly/
https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/
https://hacks.mozilla.org/2019/08/webassembly-interface-types/
https://blog.mozilla.org/luke/2015/06/17/webassembly/