What is WebAssembly(WASM)?

BYqe...FixS
12 Jan 2024
49

Web Assembly, popularly referred to as WASM, is an open source framework that allows programmers to use source code or modify it as the developer desires. WASM takes this one step further with a binary instruction format for a stack-based virtual machine (VM). It is used as a portable compilation target for high-level programming languages. It is a small, fast binary option that promises near-native performance for web applications.

WebAssembly is designed to serve as a build target for any language, including JavaScript. This means developers can compile programming languages ​​like C/C++,GO ,RUST , and more into a single standard that can be run almost natively in browsers as a close alternative to JavaScript.

Developers can leverage Web Assembly for high-performance use cases such as games, music streaming, video editing, and Computer-aided design (CAD) applications. Many web services such as Google Earth.

History of WebAssembly

-WebAssembly was developed to solve the need for improved web performance and the desire to introduce a wider range of languages ​​to the web platform. In 2015, the WebAssembly Community Group, consisting of Mozilla, Google, Microsoft, and Apple, created a new binary format. In 2017, WebAssembly MVP (Minimum Viable Product) was released to provide a stable foundation for binary format, execution model, and integration into the web platform.

The next release was browser support, where major browsers such as Chrome, Firefox, Safari, and Edge included WebAssembly. Developers discovered the usefulness of the technology outside of web browsers and began exploring the use of WASM in the field of server-side environments for high-performance computing.

How Does Web Assembly Work?

To understand how WebAssembly works, you need to understand how the JavaScript engine works. To compile JS code, the engine does a few things like passing the code through the Parser, which is a tool that goes through the code line by line and verifies valid syntax as well as code types. Once this is complete, the Parser creates a tree data structure called an Abstract Syntax Tree (AST).
Once the AST is created, the engine interpreter takes the AST and converts it into Bytecode, which is an intermediate representation of the code. The engine compiler then takes the Bytecode and converts it into code that the machines can run on their processors.

WebAssembly works differently than JavaScript and is said to be faster because WASM code goes directly to the compiler, effectively skipping steps one and two in the JavaScript process. This is because unlike JavaScript, which is a dynamically typed language, WASM is a statically typed language, meaning types are declared ahead of time when the language is written; so they are known and checked at compile time.

So when you write WASM code, you write the code with its types, usually in a statically typed language. You then create a precompiled WASM module, and finally, you bypass the parsing and conversion phase and move on to the Intermediate Representation phase, running the code directly by the engine compiler.

WebAssembly ve Ethereum

WebAssembly is currently seen as a close alternative to the Ethereum Virtual Machine (EVM). This is because, through WebAssembly, developers are now equipped with an effective set of instructions with which different languages ​​can be compiled while ensuring that they work effectively on different platforms. The WebAssembly instruction set can be easily specified by deleting floating point instructions, making it a viable alternative to EVM. Ethereum has shown interest in WebAssembly and is leading efforts to develop Ethereum WebAssembly (EWASM), a proposed redesign of the Ethereum Virtual Machine. Once successful, EWASM is expected to be more efficient and allow developers to write code in various languages ​​due to its ties with WASM. EWASM will work like EVM as a precompiled bytecode language that will be interpreted on Ethereum nodes. With this, dApps will become more efficient in production. The integration of WASM will make the development of smart contracts more accessible for people accustomed to popular languages ​​such as Rust and Go. This eliminates the need for developers to learn how to write robustly before creating useful applications on Ethereum.

Place in the ecosystem

-As the web development ecosystem is constantly evolving, WebAssembly (Wasm) plays an important role. Wasm provides a set of tools used to create high-performance applications that can run in the browser. This gives developers access to levels of performance not previously possible. Wasm's integration into the web ecosystem offers the ability to run codes written in various languages ​​in the browser. This gives developers the flexibility to use existing code written in languages ​​such as C, C++, Rust. Wasm takes web development one step further by offering efficiency and performance benefits, especially for teams developing large and complex applications.

Wasm's advantages

-WebAssembly (Wasm) provides web developers with improvements in various areas by offering a number of advantages. One of the most obvious advantages is performance. Because Wasm runs on a low-level virtual machine, it can run much faster than traditional web applications. This provides a noticeable performance increase, especially in large and complex applications.
Additionally, Wasm's portability is a major advantage. Codes can run across browsers and even on various platforms outside of the browser. This gives developers the flexibility to use the same code in different environments. In terms of security, Wasm offers a more secure solution by reducing frequently encountered security problems in the browser environment.
Thanks for reading

Write & Read to Earn with BULB

Learn More

Enjoy this blog? Subscribe to erendurden

1 Comment

B
No comments yet.
Most relevant comments are displayed, so some may have been filtered out.