How WasmGC Will Change Developer Experience

2023-11-08

Last week, Google enabled WebAssembly garbage collection (WasmGC) in Chrome. This is a significant development as it could lead to more web developers using WasmGC.

WasmGC makes it easier to develop better web applications. Additionally, it helps with memory management, porting existing code to the web, and supports faster real-time applications. Google's support for WasmGC in Chrome demonstrates their commitment to WebAssembly technology.

This update has the potential to make JavaScript slightly less popular among developers. JavaScript is widely used for creating interactive web pages.

Software developer Eloff posted on X, saying, "WebAssembly GC is a big deal. WebAssembly is like a universal machine, an instruction set that a compiler can target and run anywhere."

Prior to WebAssembly, JavaScript was one of the few programming languages available for developing web applications. However, especially for complex applications, JavaScript is not known for its performance.

WebAssembly solves this problem by allowing developers to use high-performance programming languages for web application development.

What does this mean for web developers?

WebAssembly is a new technology that allows developers to use programming languages other than JavaScript for web application development. The garbage collection feature in Wasm makes it even better as it eliminates the need for developers to manually manage memory.

WasmGC automatically manages memory allocation and deallocation, allowing developers to focus on the core functionality of their web applications.

Porting a language to a new architecture typically involves recompiling the virtual machine (VM) to support that architecture. While traditional approaches work for WebAssembly (Wasm), the Wasm garbage collection (WasmGC) proposal addresses its specific limitations.

WasmGC manages structures and arrays through the GC implementation of the Wasm VM, providing higher-level advantages and tighter integration with the target VM. It helps minimize the amount of memory management code transmitted, reduces binary size, and efficiently handles cycle collection through bidirectional links between Wasm and JavaScript, allowing for proper references between the two.

JavaScript faces fierce competition

A user on HackerNews said, "JavaScript suddenly doesn't seem to be the only real game anymore."

WebAssembly, due to its inherent advantages, may challenge the popularity of JavaScript. The compilation nature of Wasm allows it to be compiled from languages like C and C++, resulting in faster execution compared to JavaScript, which is an interpreted language known to be slower.

WebAssembly's adaptability compared to the limitations of JavaScript enhances its portability. Additionally, WebAssembly's isolation security in a sandbox environment separates it from other components of the browser, which is an advantage JavaScript lacks, as it faces more potential security threats.

The garbage collection feature in WebAssembly was proposed in 2017. However, most of the work has been completed in the past three years. With an increasing number of users building websites using WebAssembly, it has become the default option in Chrome, Edge, and Firefox.

Although JavaScript and WebAssembly play different roles in terms of performance and speed in web development, the latter stands out. Wasm is generally faster than JavaScript because it is pre-compiled and can be efficiently executed directly on hardware, while JavaScript is interpreted, resulting in relatively slower execution speed.

A published paper compared the performance of the two languages and concluded that Wasm improves efficiency by 30%.

Unlike JavaScript, Wasm code can be compiled for different hardware architectures, ensuring portability across different devices and platforms. Additionally, it supports multiple programming languages, allowing seamless interaction between them.

Wasm's execution occurs in a sandbox environment, isolating it from the main browser thread and providing improved security by limiting unauthorized access to system resources. This is a key difference between the two languages.

With the majority of online hacking attacks occurring in browsers, WebAssembly offers security advantages in multiple aspects.

Sounil Yu, Chief Information Security Officer at JupiterOne, said, "Wasm's limited instruction set and better memory management help reduce the attack surface and prevent some common types of vulnerabilities, such as buffer overflows."

Wasm code also provides a certain level of security through its unreadability, making it harder for attackers to reverse-engineer the code and discover and exploit vulnerabilities.

JavaScript has over 63% of users in web development. It is the foundation of modern web development, offering ease of use, widespread support, and seamless integration with the browser's DOM.

WebAssembly is relatively new, having been released only in March.

In a 2022 WebAssembly State of the Survey, 67% of respondents reported frequent use of WebAssembly, a significant increase from 47% in 2021. Now, WebAssembly is being used to build the most traffic-heavy websites. WasmGC will only further drive this popularity.

RECENT AI NEWS

RECENT AI TOOLS