JavaScript has been around since 1995, when Brendan Eich created the language to support Netscape, a now-defunct but aesthetically pleasing web browser that was revolutionary for its time. Since then, the ECMAScript standard has been the foundation of web page development and accounts for the majority of applications that run in the web browser, writes The New Stack.

Recently, WebAssembly (Wasm) has also appeared. After the World Wide Web Consortium (W3C) declared it a web standard in 2019, it became the fourth web standard along with HTML, CSS, and JavaScript.

But while web browser apps represent the central and historical use case for Wasm, again, it’s a matter of it being designed to run anywhere on a properly configured processor – this is where Wasm and JavaScript diverge and become more integrated for some use cases.

Wasm and JavaScript
Wasm and JavaScript are closely related, but besides JavaScript, Wasm does other things. Wasm’s original goal of helping JavaScript run more efficiently in the web browser remains a key component of their integration. Today, it extends beyond the web browser and encompasses edge and server applications for which JavaScript is not best suited.

This is due to the way Wasm works in binary format at the processor level. And lest we forget, unlike JavaScript, Wasm is not a programming language. One of the main unique features of Wasm is that its functionality allows it to work with a number of different languages in addition to JavaScript, including Python, Rust, of course, as well as Go, .NET, C++, Java, and PHP, writes The New Stack.

Wasm could give JavaScript a performance boost by compiling the otherwise interpreted language and its runtime into Wasm modules, Torsten Volk, an analyst for Enterprise Management Associates (EMA), told The New Stack. Code that is already compiled will generally run faster than code that still needs to be interpreted at runtime, such as JavaScript, he said.

Volk also says that the integration of Wasm and JavaScript works well for a wide range of applications. These include browser-based machine learning in edge locations, browser-based games requiring high performance, augmented and virtual reality applications that require low-latency execution, and applications in general that need to be able to run quickly.
He also shares that the historical co-evolution of JavaScript and WebAssembly is complementary, as Wasm was created about 20 years after JavaScript and aims to extend JavaScript use cases to more performance-demanding application workloads.

Who is better?
For pure computational performance as well as for such tasks as image processing, WebAssembly has certainly proven its advantages as being much faster than JavaScript. But the context is probably much more complex than that.

“In the browser, I think the biggest advantage of WebAssembly is the potential to use libraries from other languages. Performance is good and can be useful for web applications like Figma. But code reuse is broadly applicable to many Web applications,”

Butcher says.

Because JavaScript is a language that is accessible to almost anyone and offers many community-supported libraries that “support tons of use cases without having to reinvent the wheel,”

Volk noted.

“The fact that Wasm can be combined with ReactJS and other popular JavaScript frameworks further expands the scope of JavaScript use cases, allowing developers to deliver full-fledged enterprise applications in a simple and responsive way,”

Volk continued.

Security issues
Volk’s view is that Wasm offers security advantages over JavaScript-only code. It serves to increase the security of JavaScript code when Wasm is used as a “compiler on steroids” with which JavaScript applications can be deployed. For example, Wasm isolates JavaScript from the browser, provides memory safety, and implements strongly typed variables that are harder to use than dynamically typed JavaScript variables. And using JavaScript in Wasm provides a nice security boost” to the entire application.

But that doesn’t mean JavaScript is inherently insecure. JavaScript can be made quite secure, according to Ralph Squilas, principal program manager at Microsoft, Azure Core Upstream, in an emailed response. He fired back in defense of JavaScript that browsers are some of the most attacked surfaces on the planet. However, WebAssembly facilitates defense-in-depth with a mathematically provable sandbox model that tools like Veriwasm take advantage of.

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Editor @ DevStyleR