Is WebAssembly replacing JavaScript?

Will WebAssembly overtake JavaScript in Web Application coding needs?

Over the years, JavaScript has emerged as the go-to language for programmers who need to develop their web applications more interactive and user-friendly. But on Tuesday something drastic happened which could change the way we view or use JavaScript programming language.

On Tuesday Firefox 52 became the first browser to support WebAssembly, a new standard “to enable near-native performance for web applications” without a plug-in by pre-compiling code into low-level, machine-ready instructions.

What were the reasons for Firefox ditching two-decade-old JavaScript in favor of the relatively new WebAssembly? In this article, we look at whether WebAssembly will replace JavaScript as the preferred programming language for Web Applications.

JavaScript

JavaScript was first conceived in 1993 in the heady days of Internet Explorer and Netscape Navigator. The then king of browsers, Netscape Navigator founder Marc Andreessen believed that Netscape needed a “glue language” to support HTML that would be easy to use by Web designers and part-time programmers to assemble components such as images and plugins, where the code could be written directly in the Web page markup. Also Bill Gates’ Microsoft Internet Explorer was eating into market share of Netscape Navigator forcing Andreessen to recruit Brendan Eich with the goal of embedding the Scheme programming language into its Netscape Navigator.

In 1995, JavaScript was developed under the name Mocha, the language was officially called LiveScript when it first shipped in beta releases of Netscape Navigator 2.0 in September 1995, but it was renamed JavaScript when it was deployed in the Netscape Navigator 2.0 beta 3 in December.

Netscape Navigator met its eventual death at the hands of competition from Google;s Chrome, Microsoft’s Internet Explorer and Mozilla’s Firefox.  However, JavaScript lived on to this date powering the way how our webpages look like.

Not to be confused with Java, JavaScript is a high-level, popular, powerful, dynamic, untyped, and interpreted programming language. JavaScript is a scripting language that makes the pages interactive. JavaScript is the most commonly used programming language to create cool websites and games for the web. It derives much of its syntax from the C Language. Through JavaScript, you can add pop-up messages, etc. In recent years, JavaScript has also gained use as the foundation of Node.js, a server technology that among other things enables real-time communication.

WebAssembly

WebAssembly is a comparative tot in programming arena. WebAssembly was first announced on 17 June 2015 and on 15 March 2016 was demonstrated executing Unity’s Angry Bots in Firefox, Chromium, Google Chrome, and Microsoft Edge. WebAssembly or wasm is a low-level programming language for in-browser client-side scripting, which is currently in development. Its initial aim is to support compilation from C and C++, though other source languages such as Rust are also supported.

As it is relatively new, it does not have a rich history to boast of but relies heavily on using the popularity of C and C++ to become the preferred coding language for web application developers.

JavaScript vs WebAssembly

Till a few years back, no one would have imagined a Web Application without JavaScript. It was and still is the go-to programming language for large swathes of web developers. However, with Firefox opting for WebAssembly as preferred coding language for developing native apps and browser plugins, it could mean a turning point in web development and how our browsers work.

Why is WebAssembly superior to JavaScript?

WebAssembly uses C and C++ compilations to make its web apps work. It also supports other source languages such as Rust. But probably WebAssembly’s best weapon against JavaScript is its speed. That is the reason Mozilla trusts its future Firefox browsers with WebAssembly. Mozilla engineer Lin Clark sees this as an inflection point where the speed of browser-based applications increases dramatically.

With smartphones reaching the length and breadth of planet Earth, more and more users are joining the Internet. However, due to vagaries of service providers, the Internet speed is not the same everywhere. This creates a need for superfast web applications and fast loading browser plugins. WebAssembly looks to take JavaScript head-on with its inherent advantage in speed.

David Byrant, Head of Platform Engineering at Mozilla is apparently sold out to WebAssembly. He has written a full-fledged Medium blog post to explain why Firefox is banking on WebAssembly rather than on JavaScript for its Firefox browsers.

Byrant explains that WebAssembly will enable amazing video games and high-performance web apps for things like computer-aided design, video and image editing, and scientific visualization. Over time, many existing productivity apps (e.g. email, social networks, word processing) and JavaScript frameworks will likely use WebAssembly to significantly reduce load times while simultaneously improving performance while running. Unlike other approaches that have required plug-ins to achieve near-native performance in the browser, WebAssembly runs entirely within the Web Platform. This means that developers can integrate WebAssembly libraries for CPU-intensive calculations (e.g. compression, face detection, physics) into existing web apps that use JavaScript for less intensive work.

Will WebAssembly replace JavaScript in popularity among programmers?

It is too early to predict the death of JavaScript. However, technology is a dynamic world and in constant evolution. With virtual reality and augment reality being billed the next technological revolution, the browser are required to deliver web pages at breakneck speeds. WebAssembly is seen as a possible solution to this.

JavaScript was originally intended as a lightweight language for fairly simple scripts. It needed to be easy for novice developers to code in. You know — for relatively simple things like making sure that you fill out a form correctly when you submit it. Web apps written with WebAssembly can run at near-native speeds because, unlike JavaScript, all the code a programmer writes is parsed and compiled ahead of time before reaching the browser. The browser then just sees low-level, machine-ready instructions it can quickly validate, optimize, and run.

Byrant says that  WebAssembly could change what it means to be a web developer, as well as the fundamental abilities of the web. With WebAssembly and an accompanying set of tools, programs written in languages like C/C++ can be ported to the web so they run with near-native performance. We expect that, as WebAssembly continues to evolve, you’ll also be able to use it with programming languages often used for mobile apps, like Java, Swift, and C#.

However, till the big daddy of web, Google embraces WebAssembly in its Chrome browsers and Chromium project, JavaScript is here to stay. As a wannabe programmer, you could look to taking up WebAssembly as the demand for fast loading web apps is certainly on the rise.

8 COMMENTS

  1. Couldn’t JavaScript be compiled to WebAssembly? I don’t see why these two things are mutually exclusive. Seems like the real question is, will devs prefer JavaScript to C/C++?

    • Maybe part time programmers keep using Javascript and professional ones use c++, both of which are compiled to webassembly.

  2. Some errors here. I created JS in 1995, not 1993. IE was not out yet as such, and not hurting Netscape market share, which was still growing.

    To answer the first comment’s question, JS must be built into competitive browsers. Many years of work, an indefinite number right now, would be needed to extend WebAssembly per its roadmap and in co-evolution with JS, to even hope to map real JS workloads to wasm by compiling JS to wasm ahead of time.

    • Well Brendan, you shouldn’t be proud of that. JavaScript sucks and now the world is full of noobs the only thing they are at ease is JavaScript itself. As a consequence these people started to use JavaScript even for backend stuff, creating abominations like Node.js, Express, and many others. And now many companies, especially startups driven by the same noobs, are asking for JavaScript programmers. So the software engineering is regressing because people like you. JavaScript is a cancer.

      • in all fairness, javascripts designer cant be blamed for the “abomination” it became. at that time it was to simplify things for engineers and developers, i highly doubt they had anticipated what would happen. but honestly i have to argue a little bit, i am in agreement with the noobs who make start ups knowing nothing but javascript 100%.

        in regards to saying its horrible and evil is wrong. personally i prefer .net for alot of work but when i do prototypes of apps and everything i use javascript mostly to develop it. its nice easy to use and heavily documented so it makes working in it very simple. and why bitch about the evolution of something? they found that many friggin uses for js, which is amazing since it was developed as a scripting language to make web pages prettier. now it does everything.

        ive been coding for a long time now (since about 2008) and for 3 years in a more professional capacity and honestly in a lot of cases simplifying work loads is a much better solution for future endeavors. take the easy work while its available right? bitch now and miss the opportunity to make quick easy money, not to mention easy references for finding better employment down the road.

        sorry for my shitty grammar.

      • +1 on the “JavaScript is cancer”. A cancer imposed by lack of foresight and inertia. Now we’re all stuck with this hegemonic subpar language for the browser, and no amount of transpiling can quite solve what’s wrong with it. Even the coming of WebAssembly has been damped, coaxed into not replacing but “complementing” JavaScript.

        JS is a hodge-podge of borrowed things, and it doesn’t even do that right. It pretends to draw on functional and OOP features, but it strips them of their key advantages (e.g., function.bind — the poor man’s unspeakably awkward replacement for currying.) It’s a notorious violator of the No Surprise principle. Weak typing that allows downright senseless things like adding pears to apples without properly reporting it as an error. That’s a cornucopia of hard-to-trace bugs right there.

        There’s a legitimate reason to disfavor JavaScript, if you needed one: its shortcomings mean it’s terrible for productivity. Of course, if JS is the only thing you know, you have no perspective of how bad it is compared to… nearly everything else. Viva Dunning-Kruger.

  3. First of all, you claim that Firefox ditched JavaScript in favor of Webassembly. Who sold you those drugs man? Webassembly is NOT a replacement for JavaScript, it’s a compliment to it. Webassembly is not about making websites. It’s about doing computation intense things with native speed. You know, game routines, computations. It’s not designed for creating websites. Period. There is a niche that Webassembly will fill, that previously held by Java applets, remember those? And Flash, and Silverlight, the plugins everyone loves to hate. Have you every heard of Web Workers? They were added to JavaScript to provide concurrency and a faster way to process computation intense operations. Webassembly ditto. And if someone is stupid enough to try to create a website with just Webassembly, it will be just as successful as Java applets. In 1998 I created a website with only pure C as a cgi script. Ugh, that was way too much work, and was unmaintainable. I learned my lesson.

    If people use Webassembly for the things it’s good for, it will be a big success. However if they think they can replace JavaScript, CSS and HTML by using Webassembly, it will wind up in the trash bin with the ghosts of applets, Flash and Silverlight. People who only want to write C/C++ and hate JavaScript are simply not going to be able to make Web experiences that people are going to like.
    For a reminder, Flash used ActionScript, which was much more advanced that JavaScript. And Silverlight let you write you website in C# and .NET. Since it’s introduction there have many many attempts to replace JavaScript. But JavaScript has never been still, it keeps evolving and becoming more useful for more use cases.

    By the way, you probably should have red the Webassebly faq about use cases. These are not tasks JavaScript currently covers: https://webassembly.org/docs/use-cases/. On top of that, Webassembly is just a replacement for asm.js, which was not meant to be a replacement for JavaScript. It’s a compliment.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Read More

Suggested Post