WASM (Web Assembly)


wasm is a binary format that can be read by all browser.

WebAssembly is “a bytecode for the Web”

It’s a technology with the potential to become a truly multi-vendor, multi-platform, safe, polyglot programming platform.

You can therefore create a function in any language (java, php, …) and compile it to the wasm format to make it available in your page.

WebAssembly is defined as a virtual instruction set architecture (ISA) for a structured stack-based virtual machine. https://github.com/WebAssembly/design/blob/main/Rationale.md

In a structured stack machine:

  • most computations use a stack of values,
  • but control flow is expressed in structured constructs such as blocks, ifs, and loops.

It is a very significant departure from the way, say, the JVM works.

Moreover, in the WebAssembly language, some instructions can be represented both as “simple” and as “nested”.

with WebAssembly you get a slice of linear memory, and then you can do whatever you want with it. Allocate, deallocate; even move it around if you’d like. It is no coincidence that most languages targeting WebAssembly today really manage their own memory.


JavaScript runtimes should be able to load and link WebAssembly binaries (ie the browser, Node.js, …)

But there are also many standalone pure-WebAssembly runtimes such as:

  • Wasmtime,
  • WasmEdge,
  • wasmCloud,
  • Wazero

These runtimes are usually lighter-weight than a full-blown JavaScript engine, and they are often easy to embed inside larger projects.

polyglot target

many projects are starting to embrace WebAssembly as a polyglot platform to host extensions and plug-ins.

For instance Fastly has developed a platform for serverless computing at the edge, where the serverless functions are implemented by user-provided WebAssembly executables.

Fermyon is a startup that is developing a rich ecosystem of tooling and Web-based APIs to write Web apps using only Wasm


System Interface

WASI is the WebAssembly System Interface.

You can think of it as of a collection of (POSIX-like) APIs that allow a Wasm runtime to interact with the operating system.

It is a thin layer of capability-oriented APIs for interaction with the operating system (one level below the jdk.

WASI allows to define backend applications that directly interact with the operating system without any extra layer, and without ad-hoc APIs. 1)

WASI APIs include things like:

  • file system access,
  • networking
  • and even threading APIs.

These APIs work hand-in-hand with the lower-level capabilities of the runtime, enabling easier ports to the platform.

2) do not target Wasm, but still target browser runtimes:

  • J2CL (successor to GWT) is a source-to-source translator (i.e. a transpiler) from Java to JavaScript, which has recently gained support for Wasm.
  • Bck2Brwsr is another compiler from bytecode that targets JavaScript and the browser
  • Kotlin/Native also supports being compiled to Wasm via LLVM. It comes with all the caveats of Kotlin/Native (e.g. it may not support all of your Java libraries)

Java as web assembly runtime

  • graalvm truffle

Try it https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Control_flow/if...else ((https://news.ycombinator.com/item?id=34103142))

https://www.javaadvent.com/2022/12/webassembly-for-the-java-geek.html) )Java translation to WebAssembly. Most of them target the browser. translators from Java bytecode into WebAssembly:

Discover More
Card Puncher Data Processing
How to use ffmpeg in a web page ?

Thanks to the wasm format , it's possible to integrate ffmpeg in a web page. * * With where you can compress & resize videos in...

Share this page:
Follow us:
Task Runner