DEV Community

Josie Bigler
Josie Bigler

Posted on

JavaScript vs WebAssembly, see the difference

As a younger lad, exploring the world of Programming, a very dear friend and mentor of mine showed me the wonderful Conway's Game of Life. It's more a simulation than a game. My mentor had implemented theirs in C, printing the results to the console.

I saw it as a fun way to try and think about performance. While the logic is straight forward the calculation is heavy, especially compared to anything else you're doing as a Web Developer.

I'm not a low-level developer. Which means my implementation was in JavaScript. My first attempt was bad, like REALLY bad. I kept working on improving performance, until I came to what I have now.

My JavaScript implementation of Conway's Game of Life. I'm sure there's ways to improve the performance, but I haven't found any online. Most of the beautiful versions online only display on a smaller screen (and thereby reducing the number of calculations).

Now let’s talk about Web Assembly. Depending on who you ask Web Assembly is somewhere between the next version of Silverlight (bad) to a JavaScript killer (good?).

In order to see for myself, I set out to find a Web Assembly implementation of Conway’s Game of Life. I found an example in the creators of AssemblyScript.

Here it is!

LOOK HOW BUTTERY SMOOTH THAT IS!

MY God, Web Assembly blows my implementation out of the water.

WebAssembly offers a real, tangible benefit with its near native performance. Any technologies built ontop of WebAssembly, to me, just got more exciting. This includes the afformentioned AssemblyScript and Blazor.

Top comments (0)