Rust programming language is meant to write software for low-powered hardware devices, the majority of which include IOT devices, embedded devices such as industrial machines, robotic devices, etc.
WebAssembly is a virtual machine (a software program) that is inbuilt into modern browsers, such as Chrome, Firefox, Safari, Edge, etc., to download and execute a binary file(s) (a compiled software program specified in the <script>
tag in your HTML file) inside the browser.
A majority of WASM software programs are written in the Rust programming language. Though these can be written in C/C++ and Ruby-Lang too.
WASM binary files are included in the HTML files the same way Javascript files are included inside a to tell your browser that there is a web-assembly file that it needs to download and execute.</p> <script src="mymodule.wasm">
Unlike Javascript which is interpreted on the run, from the source file, without any compiling; WASM binaries are pre-compiled files meant for fast execution and safety.
Java Applets and Adobe Flash were the same, a software program pre-compiled into a binary file running within the browser.
And similar to WASM binaries needing a software program in the browser to get downloaded and executed, both the Java Applets and Adobe Flash needed a browser plugin to get downloaded and executed within the browser.
https://steveklabnik.com/writing/is-webassembly-the-return-of-java-applets-flash
During my early days in software programming, I built a few websites based on Java Applets and I seriously remember the nightmares I used to have while debugging those.
https://stackoverflow.com/questions/868111/how-do-you-debug-java-applets
In 2023, I use either Ruby or JavaScript for building software applications, using VIM and Visual Studio Code, and both programming languages are really easy to debug on the fly than C/C++ and Java, and Rust.
I wouldn't definitely want to go back to the old days of having debugging nightmares and waiting hours while my Rust or C/C++ files for WASM are getting compiled.
https://media.giphy.com/media/tXL4FHPSnVJ0A/giphy.gif
I would say, using WASM would make more sense than JavaScript only where there is a need for a CPU-intensive software program execution because of being written in Rust and compiled.
The best examples could be:-
Games inside the browser
Image, audio, and video editing inside the browser
Machine learning computations inside the browser
Etc
Do you have any other examples where WASM could be used best? Please comment.
Top comments (0)