WebAssembly

From Internet Computer Wiki
Jump to: navigation, search

WebAssembly is a virtual machine (VM) designed for client, server and blockchain applications. It is used to run canister smart contracts on the Internet Computer (IC). WebAssembly runs portable byte code instructions that are created by compiling software code written in programming languages such as Rust and Motoko. Because it's faster, more efficient, and more portable than the alternatives, WebAssembly is key to building efficient applications on the internet.

WebAssembly (or "WASM") was co-designed by Andreas Rossberg, who joined the Dfinity Foundation early in 2017 to work on its canister smart contract execution environment, and the Motoko language. The standard is maintained by the World Wide Web Consortium.

WebAssembly has quickly established itself as the internet's favorite virtual machine. Now every major web browser can run WASM modules imported by HTML, Cloudflare uses it to provide "cloud worker" functionality, and advanced blockchains can use it to run high performance smart contracts.

The Internet Computer uses the WebAssembly VM to run its canister smart contracts for a number of reasons, including:

  • It is formally specified, which increases its security.
  • It provides near-native performance, greatly improving smart contract efficiency.
  • It is targeted by LLVM, which means large numbers of programming languages can easily be used for smart contract creation.
  • It has been very widely adopted as the new standard for computation on the Web, and consequently a massive decentralized R&D effort constantly evolves and improves the standard, and a large variety of virtual machine implementations have been created.

Andreas Rossberg has proposed several improvements to WebAssembly that are working their way through the standards process, including WASM multi-memories, which will be used by the Internet Computer to add hardware parallelism to smart contracts, without the need to introduce concurrency constructs into smart contract code.

Andreas also led the effort to design the Motoko programming language, which is designed to take full advantage of WebAssembly features, and adapt them in respect of special Internet Computer features such as actor model smart contracts and orthogonal persistence.