Hello world with web-assembly

Search for a command to run...

No comments yet. Be the first to comment.
Image Generated using Midjourney I recently published this article, where I am talking about some MidJourney tricks and tips after which I got some messages saying what I Midjourney. I know my bad, I did not talk about Midjourney a lot in that articl...

Most of these tricks work with BlueWillow, Stable Diffusion, and many other models. Image generated using BlueWillow Midjourney is all over the rage right now, people are going crazy over it and trying different prompts to create beautiful artwork bu...

Photo by Towfiqu barbhuiya on Unsplash This is part 3 of the Managing your Finances article series, if you have not read part 1 and part 2, then I would recommend you to read those before starting with this article. You have started the journey and y...

Photo by micheile henderson on Unsplash This is part 2 of the Managing your Finances article series, if you have not read part 1, then you can read it here, after which you can resume this article. If you are sorted with your current financial situat...

Photo by Mathieu Stern on Unsplash Before starting the journey of Financial Freedom or even improving our finances, we should be prepared by assessing our current financial situation to avoid bumps during our journey. Think of this preparation as col...

Working of Web-Assembly
Web-assembly is binary code or bytecode which does all the heavy lifting of logic and which can be used in your javascript.
Yes, browsers can understand the binary and since it’s bytecode, written with a statically typed language like Rust or C/C++, it can give you better performance.
I am no expert in Web-Assembly / WAMS, I am also learning, so in this article, I will be sharing a simple example which will help you understand the working of Web-Assembly and get started with it.
Let’s get started:
To generate the WASM bytecode, I am using the following tool: https://wasdk.github.io/WasmFiddle/ which builds .wasm modules for you from a C-Program.
I am using the following simple c-program for calculating the factorial of a number.
A simple C-Program for calculating Factorial of a number.

Demo on WASDK website
Simply paste your C language code in the top-left section, click on build, which will compile and build the WASM file or return an error if code has any syntax errors.
After building just click on the WASM Download icon to download the WASM file (bytecode / binary code) to be used in the Application.
Most modern web-browsers execute web-assembly out of the box.
You just need to load the .wasm file and you can start executing functions from the .wasm file directly using Javascript.
Using the WASM file in your Javascript.
That’s all…
Thank you for reading.