Skip to main content

Introduction

This repository shows examples of WebAssembly application in some languages.
Sample application calculates the maximum prime below "N" for given "N".
Sieve of Eratosthenes which is an old but very simple algorithm is used for calculation.

Languages

WebAssembly Available

These are the part of languages which can be compiled to WebAssembly.

WebAssembly Unavailable

These languages cannot be compiled to WebAssembly directory.
But, there are some projects compiling interpreters or runtime to WebAssembly which make these languages available on browsers.

Demos

Demos are available for these languages.
The performance will depends on the environment. But generally, WebAssembly shows better performance than JavaScript for this type of calculation.

caution

WebAssembly does not always show better performance than JavaScript. It depends on the tasks.

  • C (Compiled with emcc)
  • C++ (Compiled with em++)
  • Go (Compiled with Go)
  • Go (Compiled with TinyGo)
  • Rust (Compiled with wasm-pack)
  • AssemblyScript (Compiled with asc)
  • Java (Compiled with JWebAssembly)
  • Python (Using pyodide WASM interpreter)
  • TypeScript (Not WASM)
  • Raw JavaScript (Not WASM)

Reference Implementation

This is the Python implementation of Sieve of Eratosthenes.
Demos in other languages are written to corresponds to this program as possible.

python/prime.py
loading...