Mozilla working to make Rust Programming language like JavaScript, for use alongside WebAssembly in web apps



The nonprofit Internet giant, Mozilla is poised to bring interoperability to its programming language, Rust to work alongside WebAssembly and JavaScript in web application development.

Mozilla has created a bridge between the types in JavaScript and the Rust language, called wasm-bindgen, to build on the WebAssembly portable code format, with wasm-bindgen providing high-level interactions between WebAssembly (wasm) modules and JavaScript.

In turn, JavaScript and WebAssembly would be able to communicate with strings, JavaScript objects, and classes instead of just integers and floats.

While WebAssembly supports only two integer types and two floating-point types, making four in total, JavaScript and Rust developers often require richer types, like Rust developers working with Result for error handling.

But with the bridge between WebAssembly and JavaScript, wasm-bingden, JavaScript could invoke WebAssembly functions and WebAssembly could do the same for JavaScript functions. And JavaScript could also call a Rust API with a string or a Rust function to catch up with a JavaScript exception.

The wasm-bindgen high-level functions include, exporting of Rust structures and functions to JavaScript, and import of JavaScript functions and objects to WebAssembly.

Though, wasm-bindgen is built on ECMAScript modules, the goal is to eventually be used alongside languages like C and C++. Albeit, Mozilla maintains that wasm-bindgen isn't yet ready for expansion to other programming languages.
Previous
Next Post »