Today’s approach: transpiling
The procedure for “ rewriting ” a program from one language to another is called transpiling. And it has several obvious flaws.
The syntax and functions of high-level programming languages are different. Therefore, it is often simply impossible to construct equivalent constructions. But even if you manage to find them, there will definitely be problems that are hard to avoid.
For example, what happens if you stop developing a transpiler? Will it cause bugs? Or will you need to connect the JS framework? And how can a team work when everyone uses different languages?
Tomorrow’s technology: asm.js
For the first time, new opportunities loomed on the horizon in 2013 thanks to Asm.JS, an experimental project from the creators of Mozilla. They tried to find a way to run high-performance code inside the browser. And if the plugins tried to follow the browser, asm paved the way straight through the JVM.
Simply put, asm.js complies with the basic law of not breaking the Web, indicating a direction for further development.
WebAssembly was created in 2015. Now it is supported by 4 large browsers (Chrome, Mozilla Firefox, Edge and Safari) both on desktop and mobile devices. As for Internet Explorer, there is no support, but you can provide backward compatibility by converting the wasm code to asm.js (performance suffers in this case).
The WebAssembly tool gives developers a way to write optimized procedures, mostly in C ++. This ability is very powerful, but narrowly targeted. It is used only to increase the efficiency of complex calculations. For example, fastq biousing wasm accelerate the process of reading DNA. It is also used when porting high-performance games, as well as for creating intra-browser emulators.
Virtual machine inside a second virtual machine
For example, the Microsoft Blazor framework uses the .NET environment, which loads as a compiled Wasm file. It works with JS and provides garbage collection along with other basic services, as well as higher-order functions. In simple words, Blazor uses a virtual machine inside a second virtual machine. And this is just one example. Besides Blazor, there are other experiments based on WebAssembly. Take Pyodide, hosting the Python language in the browser, complemented by an expanded list of mathematical tools for working with data.
What is this if not a confident step in the advanced technologies of the future? WebAssembly was originally designed for C++ with Rust, and now it is used in more ambitious projects.
Wasm is growing rapidly. Its current state is just the minimum threshold that is enough for use in only a few important scenarios. But after the approval of WebAssembly, the situation will change for the better.
If Blazor and similar platforms become popular, WebAssembly is likely to gain direct access to the DOM. And browsers will take over the implementation of such details as multithreading and the garbage collector (at least, their creators are now nurturing such plans).