Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/shadownrx/windows/llms.txt

Use this file to discover all available pages before exploring further.

When NEX OS runs real-time operations like Task Manager metrics, JavaScript alone is not enough. The JavaScript main thread can saturate quickly when performing complex calculations every few milliseconds, causing the UI to stutter or freeze. To solve this, NEX OS delegates those CPU-intensive operations to WebAssembly (WASM) — compiled binary code that executes at near-native speed inside the browser, without blocking the React rendering pipeline.

Why WebAssembly?

JavaScript is a dynamic, garbage-collected language, which means it occasionally pauses execution to free memory. For applications that demand consistent, low-latency throughput — like polling system metrics 60 times per second — those pauses are unacceptable. WASM sidesteps this entirely: it runs pre-compiled binary, has no garbage collector, and communicates with JavaScript through a lean, efficient bridge.

Performance Comparison

OperationJavaScriptWASMImprovement
Process 1M numbers150 ms1.5 ms100x
Process dataset50 ms0.5 ms100x

WASM Advantages

Fast Execution

Code is compiled to binary and runs at near-native CPU speed — no interpretation overhead.

Deterministic

No garbage collector pauses. Calculations always complete in predictable time.

Non-Blocking

WASM runs off the main JavaScript thread, so the UI stays fully responsive.

Low Overhead

The JS ↔ WASM bridge is extremely efficient, minimizing round-trip cost.
The compiled process_utils.wasm binary is approximately ~50 KB — small enough to be cached immediately by the browser’s service worker on the first load.

Two WASM Engines in NEX OS

NEX OS ships two complementary WebAssembly modules, each suited to a different authoring style and use case:

AssemblyScript — assembly/index.ts

AssemblyScript uses TypeScript-like syntax and compiles directly to WebAssembly using the asc compiler. This makes it the most approachable option for TypeScript developers already familiar with the NEX OS codebase. The source lives in assembly/index.ts and is rebuilt with a single command:
npm run build:as
This produces public/process_utils.wasm and the accompanying public/process_utils.js ESM wrapper. See AssemblyScript Module for the full authoring and compilation guide.

Rust — wasm-engine/src/lib.rs

The Rust WASM engine provides the full power of a systems programming language: ownership, lifetimes, traits, and access to crates from the Rust ecosystem. It is used for more complex operations including the C++ transpiler that backs the Dev-C++ 2026 application. See Rust Engine for details.

Where WASM Is Used in NEX OS

WASM is not used everywhere — only in places where JavaScript performance is genuinely insufficient.
FeatureModuleFunctions Used
Task Manager — real-time CPU/memory metricsAssemblyScriptcalculateLoad, getRank
Dev-C++ 2026 — C++ transpilerRustwasm-engine/src/lib.rs
Process managementRustwasm-engine/src/lib.rs

The useWasmEngine Hook

All WASM consumption in NEX OS goes through the useWasmEngine hook located at src/utils/useWasmEngine.ts. This hook handles module loading asynchronously and provides an automatic JavaScript fallback — if the browser cannot load the WASM binary for any reason, the hook transparently switches to a pure-JS implementation of the same functions.
import { useWasmEngine } from '../utils/useWasmEngine';

const { isReady, isWasm, calculateLoad, getRank } = useWasmEngine();

if (!isReady) return <div>Loading...</div>;

const load = calculateLoad(0.7, 0.4);
const rank = getRank(load);
// isWasm tells you whether WASM or the JS fallback is active
The isWasm boolean is useful during development and debugging — log it to confirm your browser loaded the binary successfully instead of silently falling back to JavaScript.
Always guard on isReady before calling calculateLoad or getRank. The WASM module loads asynchronously on mount; calling these functions before the module is ready will throw a runtime error.

Next Steps

Dive into the implementation details for each engine:

AssemblyScript Module

Write and compile TypeScript-like WASM functions. Covers types, the build pipeline, React integration, and limitations.

Rust Engine

Explore the Rust WASM engine powering complex operations like the C++ transpiler and process management.

Build docs developers (and LLMs) love