Google Chrome logo.

Most websites and web applications are written in JavaScript, or at least something that is converted to JavaScript. There have been many attempts over the years to change that, but don’t expect JavaScript to completely go away anytime soon.

Zaplib is a startup company that created a framework for rewriting parts of JavaScript-based web applications in the Rust programming language, which would then run in web browsers using WebAssembly. Rust is a low-level programming language optimized for performance and safety, and many applications have used Rust to significantly improve load times and responsiveness. Mozilla rewrote the CSS engine in the Firefox web browser using Rust in 2017, as part of the ‘Firefox Quantum’ update, which doubled Firefox’s typical performance. WebAssembly allows sites to write their code in more traditional programming languages, like C++, and run it inside a web browser just like JavaScript.

Zaplib hoped that rewriting web applications in Rust-powered WebAssembly, one section at a time, would result in performance boosts as much as 10x. However, the company’s founders said in a ‘post-mortem’ that the massive jumps didn’t quite pan out. “Our bet was that it would be 10x more ergonomic to speed up your app, incrementally, in Rust. This did not hold up in real-world implementations,” the team said.

The group noted a few problems with its plan. Most companies were (understandably) hesitant to rewrite their code in a language their engineers might not have been familiar with, but more importantly, there wasn’t a significant speed difference between good JavaScript code and good Rust code. Zaplib helped one company port a simulation tool to Rust, which only ended up being 5% faster than the existing JavaScript version. Zaplib also hoped its hardware-accelerated 2D renderer would help, but most of the performance boost there came from WebGL, which doesn’t need Rust or WebAssembly at all.

This doesn’t mean WebAssembly is terrible or unhelpful — Google Earth and Photoshop were both ported to web browsers thanks to WebAssembly, and companies like Microsoft are building frameworks for more developers to make the same transition. There’s absolutely a reason for it to exist, but JavaScript has also evolved significantly in the past few years. The ‘V8’ engine that handles JavaScript code in Chrome, Microsoft Edge, and other Chromium-based browsers is constantly becoming faster. Recent optimizations made Chrome the fastest web browser available on the Mac, according to Google, and other changes have sped up the Windows and Android versions too.

WebAssembly is already bringing a new wave of applications to the web that couldn’t have existed a few years ago, but don’t expect all JavaScript to go away anytime soon. Zaplib said in its post, “there are usually simpler ways to find performance improvements than Rust [or WebAssembly].”

Source: Zaplib

Profile Photo for Corbin Davenport Corbin Davenport
Corbin Davenport is the News Editor at How-To Geek, an independent software developer, and a podcaster. He previously worked at Android Police, PC Gamer, and XDA Developers.
Read Full Bio »