WebAssembly: the beginning of a new internet era

Lionel LindtBy Lionel Lindt / 30.04.19
webassembly-the-beginning-of-a-new-internet-era
arrow-back

WebAssembly is the new trend term in web development. It is intended to complement JavaScript and will soon be able to execute code in any written programming language on the web.

What is assembler?


«Assembler language» is a programming language that is classified one level higher than the direct machine language.
The processor manufacturers have each defined individual instructions («codes») for their processor in binary form. The programmer could write these instructions to a file, which was then read and executed by the processor. These codes enable the whole functionality of a computer application, which consists in the background only of memory manipulation/shifting.
The codes as numbers were very difficult for programmers to remember (e.g.: 11111010 binary and FA hexadecimal). That's why manufacturers started to give names and abbreviations to the codes, which the developers could see and use (e.g.: ADD, MOV, PUSH etc.).
Assembler is able to understand and execute these abbreviations. In assembler you take any data value (in the form of a memory address) and perform an operation on it, which usually results in a new value that can then be reused. However, new data can also be read in and used constantly. «Higher languages» such as «C» make use of assembler by first compiling (translating) them to assembler language (machine language) and then «down» to machine codes.
Wie funktioniert Assembler

What is WebAssembly (WASM)?


On the web, «web pages» are basically written in languages such as HTML, CSS and JavaScript. The JavaScript language has developed enormously since its beginning (1995) and programmers can use it much more widely today than at that time. Nowadays JavaScript can also be used on the server side (for example as Node.js), which means that it can extract and process the data stored on a server. This procedure is used above all when dynamic data is available. For example, with a list of all users on a page, each data record does not have to be written manually, but the server-side language can read the data from the database and transfer it to HTML.
JavaScript offers many advantages and is very popular as a scripting language, but advantages like dynamic types can also be seen as disadvantages. Another disadvantage of JavaScript is its performance. JavaScript is interpreted like HTML, i.e. it is «translated» line by line for the computer. In contrast, so-called «compiler languages» are already understandable or «translated» for the machine. This leaves more time to make certain optimisations.
Since the beginning of 1995 JavaScript has increased performance, because browsers have started to recognize patterns in every interpretation of the code and to save them. As a result, the optimised version of the code can be loaded. (This optimisation is known under the term «JIT», which stands for Just-in-time compilation).
Nevertheless JavaScript loses performance, if only because of the fact that this optimisation has to be done by the browser.
Mozilla, the company behind Firefox, Thunderbird and JavaScript, released WebAssembly (WASM) in March 2017. WebAssembly works similar to the «real» assembler:
WebAssembly can also be translated into binary format as machine code, and compiler languages – languages whose code is translated into machine language prior to execution, such as C, C++, or Rust – can be compiled («translated») into WebAssembly.
However, since the Web does not know the processor architecture of the user of a page that uses WebAssembly, WebAssembly has yet to be compiled into the appropriate assembler. The programs compiled with WebAssembly must then be loaded into JavaScript using so-called «modules».
WebAssembly now solves its performance problem as a supplement to JavaScript. Compilable and thus very fast «non-resource-hungry» programs, which for example were written in C, could not be executed via the web, but only with JavaScript as mentioned before.
Thanks to WebAssembly, these programs can now be used on the Internet. This makes WebAssembly one of the most important new features in web development, as it takes advantage of the compiler languages.

Use


Since the release of WebAssembly many innovative and interesting applications have been developed. The functionality of WebAssembly not only allows new apps – which can be written in the developer's favourite compiler language – to be executed via the browser, but also other desktop applications to run over them without any problems thanks to a few adjustments. Also, «old» programs or games that have not been used often for a long time can be executed in the browser, which would arouse new interest in them and make them popular again. As an example: Someone took the trouble to revive the formerly very popular Windows 95 with WebAssembly.

These blog entries may also interest you: