Hundreds and hundreds of C code. BOOM! You need them all translated to Javascript in few hours! Hard algorithms to handle and almost nothing to optimize.

Don’t panic! Emscripten is here to help us in this difficult task.

Emscripten is an LLVM-to-JavaScript compiler. It takes LLVM bitcode – which can be generated from C/C++, using llvm-gcc or clang, or any other language that can be converted into LLVM – and compiles that into JavaScript, which can be run on the web (or anywhere else JavaScript can run).

Using Emscripten, you can

Compile C and C++ code into JavaScript and run that on the web

Run code in languages like Python as well, by compiling CPython from C to JavaScript and interpreting code in that on the web

Steps are, relatively, easy:
1) Download the code;
2) Unzip it and go into the folder;
3) Run the following command:

./emcc --help

At this point, a file containing the main path dependencies will be created, and Emscripten will be ready to use (crossed fingers for dependencies).

Now let’s try this command:

./emcc tests/hello_world.cpp -o my_first_example.html

The command above will generate, if successful, three files (a *.html, *html.map and a *.js where the main bitcode has been translated to Javascript).

Double click on the html file and watch the awesomeness on you browser
That’s it!!! I suggest to go through the generated code to understand how everything has been translated and a plus would be comparing the existing codes (Javascript vs C/C++) to understand the logic.