Skip to content

WebAssembly (WASM) Compiler

Compiles HoloScript to WebAssembly binary modules — portable, near-native speed execution for the browser, server (Node.js/Deno), and edge runtimes.

Overview

The WASM compiler (--target wasm) generates .wasm binary modules from HoloScript logic definitions. Physics simulations, collision detection, pathfinding, and procedural generation all run at near-native speed inside the WASM sandbox — with a thin JavaScript bridge for DOM/WebXR integration.

bash
holoscript compile scene.holo --target wasm --output ./dist/

Output Structure

dist/
  holoscript.wasm      # Core logic binary
  holoscript.js        # JS glue / bindings
  holoscript.d.ts      # TypeScript types
  assets/              # Static scene data

What Gets Compiled to WASM

HoloScript SystemWASM ModuleWhy WASM?
Physics simulationphysics.wasm60fps rigid body at 100+ objects
Pathfinding (A*)nav.wasmLarge navmesh without stutter
Procedural geometryprocgen.wasmReal-time mesh generation
Collision detectioncollision.wasmSub-ms broad-phase
SNN / neuromorphicVia NIRToWGSL + computeGPU path preferred

Rendering, networking, and XR input stay in JavaScript and call into WASM for computation.

Trait Mapping

HoloScript TraitWASM Behaviour
@physicsFull WASM physics step per-frame
@pathfindingWASM A* / flow-field
@collidableWASM broad+narrow phase
@proceduralWASM mesh generation, JS receives verts
All othersRemain in JS bridge layer

Example

holo
composition "PhysicsBench" {
  template "Ball" {
    @physics
    @collidable
    geometry: "sphere"

    physics: { mass: 1.0, restitution: 0.8 }
  }

  spatial_group "Stack" {
    object "Ball_1" using "Ball" { position: [0, 5, 0] }
    object "Ball_2" using "Ball" { position: [0, 7, 0] }
    object "Ball_3" using "Ball" { position: [0, 9, 0] }
  }
}
bash
holoscript compile bench.holo --target wasm
# → holoscript.wasm (physics loop), holoscript.js (renderer + init)

Compiler Options

OptionDefaultDescription
--wasm-simdtrueEnable WASM SIMD (128-bit vector ops)
--wasm-threadsfalseEnable SharedArrayBuffer threading
--wasm-gcfalseEnable WASM GC proposal (experimental)
--wasm-splitfalsePer-system module splitting
--wasm-optimize2Binaryen optimization level (0-3)

Browser Support

FeatureChromeFirefoxSafariEdge
Base WASM57+52+11+16+
SIMD91+90+16.4+91+
Threads74+79+15.2+74+

Edge & Server

The WASM output runs identically in:

  • Node.js (--experimental-wasm-*)
  • Deno (import ... from './holoscript.wasm')
  • Cloudflare Workers (wasm_modules)
  • Fastly Compute@Edge

See Also

Released under the MIT License.