Why Node.js?
In Chapter 3, Setting Up a Development Environment, Node.js was described as an asynchronous event-driven JavaScript runtime, which is the definition taken from the official website. What Node.js represents, however, is a profound shift in the way we build and manage web applications. In this section, we will discuss the relationship between WebAssembly and Node.js, and why the two technologies complement each other so well.
Seamless integration
Node.js runs on Google's V8 JavaScript engine, which powers Google Chrome. Since V8's WebAssembly implementation adheres to the Core Specification, you can interact with a WebAssembly module using the same API as the browser. Instead of performing a fetch call for a .wasm
file, you can use Node.js's fs
module to read the contents into a buffer, then call instantiate()
on the result.
Complementary technologies
JavaScript has limitations on the server side as well. Expensive computation or working with large numbers can be optimized with...