07-19-2021, 12:03 PM
So what Web assembly(WASM) is?
Web assembly is a portable binary instruction format for stack based virtual machines. And can be used in games, porting desktop applications to Web, and can be used for serverless computing as well. It is designed as a portable target for compiling high-level languages like C/C++/Rust enabling deployment of code written in these languages on the web for client and server applications. The code of Web assembly is low-level assembly language just like x86 but with it's text format feature one can read the code debug if necessary.
Is it faster than javascript?
I would say yes, if the code is cached on browser it can load more faster than JS.
Advantages:
1. WASM is supported on all the major browsers like safari, chrome, Firefox.
2. It has multiple language support. Languages like C/C++/Rust/Go can be compiled to Web assembly and run the same code written in these languages on the browser efficiently. That means the languages which are not able to run inside the browser will now be able to do so.
3. It is faster, efficient and portable due to the small size of code.
4. It is easy to understand and one can work with it without any problem as you don't have to write code in Web assembly you can write code in any high-level languages which support compilation to wasm and execute it on Web.
Disadvantages :
1. WebAssembly is dependent on javascript to interact with Document Object Model (DOM).
2. It's developers are still working on it so it is too early to decide it's future.
Why do we need WASM?
For now we only have javascript which can successfully work inside a browser and there are many heavy tasks including Image Recognition, Computer-Aided Design applications, Live-video augmentation, VR and AR, Scientific visualisation and simulation etc that are difficult to implement in javascript, this is where we need Web assembly.
Also when the wasm code is loaded in browser then the browser takes care of converting the code into machine readable format which can be understood by processors but for javascript the code has to be downloaded, parsed and converted into machine which takes a lot of time to execute heavy tasks.
How Web assembly works?
C/C++/Rust > compile to .wasm > run in Web browser.
Web assembly is a portable binary instruction format for stack based virtual machines. And can be used in games, porting desktop applications to Web, and can be used for serverless computing as well. It is designed as a portable target for compiling high-level languages like C/C++/Rust enabling deployment of code written in these languages on the web for client and server applications. The code of Web assembly is low-level assembly language just like x86 but with it's text format feature one can read the code debug if necessary.
Is it faster than javascript?
I would say yes, if the code is cached on browser it can load more faster than JS.
Advantages:
1. WASM is supported on all the major browsers like safari, chrome, Firefox.
2. It has multiple language support. Languages like C/C++/Rust/Go can be compiled to Web assembly and run the same code written in these languages on the browser efficiently. That means the languages which are not able to run inside the browser will now be able to do so.
3. It is faster, efficient and portable due to the small size of code.
4. It is easy to understand and one can work with it without any problem as you don't have to write code in Web assembly you can write code in any high-level languages which support compilation to wasm and execute it on Web.
Disadvantages :
1. WebAssembly is dependent on javascript to interact with Document Object Model (DOM).
2. It's developers are still working on it so it is too early to decide it's future.
Why do we need WASM?
For now we only have javascript which can successfully work inside a browser and there are many heavy tasks including Image Recognition, Computer-Aided Design applications, Live-video augmentation, VR and AR, Scientific visualisation and simulation etc that are difficult to implement in javascript, this is where we need Web assembly.
Also when the wasm code is loaded in browser then the browser takes care of converting the code into machine readable format which can be understood by processors but for javascript the code has to be downloaded, parsed and converted into machine which takes a lot of time to execute heavy tasks.
How Web assembly works?
C/C++/Rust > compile to .wasm > run in Web browser.