DEV Community

Unpublished Post. This URL is public but secret, so share at your own discretion.

What is WASM?

WebAssembly can be described as a "bytecode" format that compilers can use to translate programs into an efficient and platform-independent representation.

+---------------------+
| High-level Code |
+---------------------+
|
V
+---------------------+
| Compiler/ |
| Interpreter |
+---------------------+
|
V
+---------------------+
| Bytecode Format |
+---------------------+
|
V
+---------------------+
| Virtual Machine |
+---------------------+
|
V
+---------------------+
| Machine Code |
+---------------------+
Enter fullscreen mode Exit fullscreen mode




Explanation:

  • High-level Code: This represents the code written in a high-level programming language, such as Java, C#, or JavaScript.

  • Compiler/Interpreter: The code is passed through a compiler or interpreter, which translates the high-level code into a bytecode format. The compiler may perform optimizations and generate the bytecode representation, while an interpreter may directly interpret and execute the code.

  • Bytecode Format: The bytecode format is a platform-independent representation of the code. It consists of a series of instructions and possibly operands or arguments. This format is designed to be efficiently executed by a virtual machine.

  • Virtual Machine: The virtual machine is responsible for executing the bytecode. It understands the bytecode instructions and performs the corresponding operations. The virtual machine is specific to the target platform and can efficiently interpret or compile the bytecode into machine code for execution.

  • Machine Code: The virtual machine translates the bytecode into machine code, which is the low-level instructions understood by the specific hardware architecture. The machine code is executed directly by the processor.

Top comments (0)