Tech Enthusiasts

Getting Started with WebAssembly

Published on September 17, 2025 by Alex Rivera

WebAssembly (Wasm) is a binary instruction format that allows code written in languages like C, C++, Rust, and Go to run on the web at near‑native speed. In this introductory post we’ll cover the basics, why you might want to use Wasm, and walk through a simple “Hello, World!” example.

Why WebAssembly?

Prerequisites

To compile to Wasm you’ll need a toolchain for your chosen language. For this example we’ll use rustc with wasm-pack.

Step‑by‑Step: “Hello, WebAssembly”

# Install Rust and wasm-pack if you haven’t already
curl https://sh.rustup.rs -sSf | sh
cargo install wasm-pack

# Create a new Rust library
cargo new --lib wasm_hello
cd wasm_hello

# Edit src/lib.rs
#[wasm_bindgen]
pub fn greet() -> String {
    "Hello from WebAssembly!".into()
}

# Build the Wasm package
wasm-pack build --target web

# In your HTML, load the generated JS

Loading in the Browser

<script type="module">
import init, { greet } from './pkg/wasm_hello.js';

async function run() {
  await init();
  document.getElementById('output').textContent = greet();
}
run();
</script>
<div id="output"></div>

Open the HTML file in a modern browser and you should see the message from the Wasm module.

Comments