Zero JavaScript Policy

Jugar enforces ABSOLUTE ZERO JavaScript in all game computation. This is a critical architectural constraint.

Why Zero JavaScript?

ProblemJavaScriptPure WASM
DeterminismNon-deterministicFully deterministic
GC PausesUnpredictable pausesNo garbage collector
SecurityLarge attack surfaceSandboxed execution
PerformanceJIT variabilityPredictable performance
ReplayDifficultFrame-perfect replay

What's Forbidden

❌ FORBIDDEN                         ✅ REQUIRED
─────────────────────────────────────────────────────
• JavaScript files (.js/.ts)         • Pure Rust only
• npm/node_modules/package.json      • wasm32-unknown-unknown
• Any JS bundler                     • web-sys (Rust bindings)
• JS interop beyond web-sys          • Single .wasm binary output
• wasm-bindgen-futures               • Pure async
• gloo, bevy, macroquad, ggez        • Batuta stack components

What's Allowed

The only JavaScript permitted is a minimal HTML loader that:

  1. Fetches and instantiates the WASM module
  2. Forwards browser events to WASM (keydown, mouse, touch)
  3. Renders output commands from WASM

Zero game logic in JavaScript. All computation happens in WASM.

Verification

Automated Check

make verify-no-js

This checks for:

  • Standalone .js files (excluding wasm-pack output)
  • .ts files (excluding .d.ts type definitions)
  • package.json in project root
  • node_modules directory
  • Forbidden crates in Cargo.toml

Manual Verification

# Check for JavaScript files
find . -name "*.js" -not -path "./target/*" -not -path "*/pkg/*"

# Check for TypeScript files
find . -name "*.ts" -not -name "*.d.ts" -not -path "./target/*"

# Check for npm artifacts
ls package.json node_modules 2>/dev/null

Forbidden Crates

These crates violate the zero-JS policy:

CrateReason
wasm-bindgen-futuresRelies on JS promises
glooJavaScript wrapper library
bevyLarge with JS dependencies
macroquadJavaScript glue required
ggezNot pure WASM

Use Batuta Stack Instead

All functionality comes from the Batuta ecosystem:

NeedUse
SIMD/GPU computetrueno
ML/AI algorithmsaprender
Renderingtrueno-viz
Platform abstractionpresentar-core
Data loadingalimentar
Asset registrypacha

Benefits

  1. Deterministic Replay: Record inputs, replay exactly
  2. Testing: Probar can test without a browser
  3. Security: No JavaScript attack surface
  4. Performance: Predictable, no GC pauses
  5. Size: Single .wasm file < 2MB