Project in Advanced Programming Language

by Lukas Bamert and Jan Grau

In the course "Advanced Programming Languages we learn to handle Advanced Programming Languages. Two of them are C++ and JavaScript including CSS and HTML. Since December 5th 2019 Web-Assembly is officialy the new kid on the block in the web browser. Because C++ can be compiled to wasm, we setup a little project in order to test some aspects of the integration. According to ChatGPT, it is wortwhile to compare those languages because of those reasons:

There are a few reasons why you might want to compare C++ compiled to WebAssembly (WASM) to JavaScript:

  1. Performance: WASM can often offer faster performance than JavaScript, particularly for tasks that are computationally intensive or require low-level access to system resources. This is because WASM is compiled to machine code, which can be executed directly by the processor, while JavaScript is an interpreted language that is executed by the browser's JavaScript engine.
  2. Reuse of existing code: If you have existing code written in C++, you may be able to reuse that code in a web application by compiling it to WASM. This can save you the time and effort of re-implementing the code in JavaScript.
  3. Compatibility with other languages: WASM is designed to be a portable, low-level bytecode that can be compiled from a variety of programming languages, including C++, Rust, and others. This means that if you are familiar with one of these languages, you may be able to use WASM as a way to write web applications without having to learn JavaScript.

It's worth noting that WASM is not a replacement for JavaScript and the two languages have different strengths and use cases. In general, JavaScript is better suited for tasks that require high-level abstractions and dynamic language features, while WASM is better suited for tasks that require low-level access to system resources or demand maximum performance.

To test this we wrote a program in javascript and in C++, which loops through each bit to try to find a u32 inverse of a value you can enter.

We will transform your value into u32 type, because Javascript is working on this datatypes for bit-wise-operations.

In the end we will show you both results and the respective time it took for both programms. Have fun!!

Please note, that it might take several minutes for the process to finish (especially on mobile devices). So please be patient.