Wasm Builders 🧱

Cover image for Implementing Quick Sort on server-side
gunjan agarwal
gunjan agarwal

Posted on

Implementing Quick Sort on server-side

In my previous post, I created C++ in the web browser using web assembly, in this post I will be implementing it server-side.

So, let's first install all the dependencies required.

  1. C++
  2. Wasmer and Wasienv
  3. Wasmtime

There are 3 steps

  1. Compile the C++ code
  2. Compile C++ code to WASM Binary
  3. Execute it using WASM Runtime

So, lets start.

Compile the C++ code

  • make the folder at any preferred location in your machine
  • open your favorite code editor and write Quick Sort C++ code.
  • Save the file with .cpp extension. (Quick sort code can be found here)

Terminal-ss

  • complile and execute C++ code.

g++ quick-sort.cpp followed by ./a.out

Terminal-ss

Compile C++ code to WASM Binary

It can be done using following command.
We have now converted our c++ code to web assembly code.

wasic++ quick-sort.cpp -o quick-sort.wasm

Execute it using WASM Runtime

Execute the following command to see the results.
wasmtime quick-sort.wasm

Terminal-ss

Happy Hacking :)

Latest comments (0)