// NODE-JS — JAVASCRIPT IN RUST

node-js v0.1.0 · JavaScript on fusevm · lex/parse → AST → bytecode → Cranelift JIT · JsHost object heap · binary node · a fusevm language host (with zshrs, stryke, awkrs, pythonrs, rubylang) · MIT · in active development

Report GitHub Issues
// Color scheme

>_NODE-JS REFERENCE

A compiled JavaScript runtime written in Rust. Source is lexed and parsed to an AST, lowered to fusevm bytecode, and executed on the same language-agnostic VM + Cranelift JIT that hosts zshrs, stryke, awkrs, pythonrs, and rubylang, over a JsHost object heap. The binary is node. In active development.

What it is

node-js runs JavaScript programs as ordinary compiled bytecode: it lexes and parses the source, lowers it to fusevm instructions, and lets the shared engine execute and JIT-compile them. There is no bespoke VM or tree-walker — arithmetic and comparisons lower to native fusevm ops so the Cranelift JIT can trace hot loops, while JS-specific behaviour (truthiness, == coercion, + overloading, ToInt32 bitwise wrap, number formatting, the builtin objects) is served by the JsHost object heap.

It is another language hosted on fusevm, the shared bytecode VM and Cranelift JIT behind zshrs, stryke, awkrs, pythonrs, and rubylang. node-js carries no VM or JIT of its own.

Architecture

The pipeline mirrors how the sibling frontends host their languages:

JS source  →  lexer  →  parser (AST)  →  lower to fusevm bytecode  →  fusevm VM + Cranelift JIT
                                                │
                                  JsHost object heap (objects/arrays/strings, builtins, numeric hook)

fusevm-hosted

No local vm.rs / jit.rs. JS is lowered to fusevm bytecode and executed on the shared Cranelift JIT; jit-disk-cache persists native code across runs.

Native arithmetic + numeric hook

Operators lower to native fusevm ops; a strict numeric hook supplies JS coercion (+ string concat, the == matrix, ToInt32 for bitwise ops) only for the non-numeric operand cases.

Arrow-function lookahead

Arrow functions are detected at assignment level by looking ahead for => after a parameter list; template-literal ${...} fields are re-parsed from the raw source (src/parser.rs).

Ordered objects

Objects, strings, and arrays live on the JsHost heap behind Value::Obj(u32) handles; property insertion order is preserved (an IndexMap), observable in iteration and JSON round-trips.

Example

const fib = n => (n < 2 ? n : fib(n - 1) + fib(n - 2));

console.log([...Array(11).keys()].map(fib).join(", "));
// => 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55

let total = 0;
for (const x of [1, 2, 3, 4]) total += x;
console.log(total);                       // => 10

const o = { b: 2, a: 1 };
console.log(JSON.stringify(Object.keys(o)));   // => ["b","a"]

const name = "world";
console.log(`hello, ${name}! ${6 * 7}`);  // => hello, world! 42

Usage

node script.js                     # run a file
node -e 'console.log(1 + 1)'       # evaluate a one-liner
echo 'console.log(6 * 7)' | node   # read a script from stdin

Errors go to stderr in terse node: <reason> form; nothing else is printed. Runnable examples/*.js ship with the crate.

Status & roadmap

A working core, grown outward from the sibling frontends. The table reflects the current state of the tree.

ComponentStateNotes
Lexer / parser → ASTImplementedTokenizer with newline tracking; arrow-function => lookahead; template-literal ${...} re-lex (src/lexer.rs, src/parser.rs).
AST → fusevm bytecode loweringImplementedNative arithmetic + CallBuiltin dispatch; func/arrow/try sub-chunks; no local VM (src/compiler.rs).
Bindings & operatorsImplementedvar/let/const; full arithmetic/comparison/logical/bitwise/nullish surface, typeof/void/delete/instanceof/in, ?:, ++/--, compound assign.
Control flowImplementedif/else, while, do…while, for, for…in, for…of, switch, break/continue/return, throw, try/catch/finally.
Functions, arrows, closuresImplementedDeclarations and expressions, arrow functions, closures, recursion, new (src/host.rs).
Literals, spread, templatesImplementedArray/object literals, member/index access, spread ..., template literals.
Builtin objects & methodsImplementedconsole, Math, JSON, Object, Array, Number, String, Boolean, parseInt/parseFloat/isNaN/isFinite, and a broad array/string method set (src/builtins.rs).
Differential parity (harness + fuzzer)ImplementedFrozen corpus replayed with no node installed (tests/parity.rs); generative fuzzer diffs node -e vs reference (src/bin/parity.rs, src/bin/parity_fuzz.rs). Dev tools, never in CI.
AOT native-exe & bytecode cacheScaffoldedCrate is a staticlib with fusevm's aot + jit-disk-cache features enabled (mirrors pythonrs), but not yet exposed on the CLI.
Classes / async / modules / stdlibPlannedclass, async/await, generators, ES modules, destructuring, default/rest params, RegExp, Map/Set/Promise, and the Node.js standard library.

Building from source

node-js builds as a standalone Rust crate (an explicit empty [workspace] keeps it independent of the meta repo):

# clone
git clone https://github.com/MenkeTechnologies/node-js
cd node-js

# build (produces target/debug/node + parity + parity-fuzz)
cargo build

# run a file or a one-liner
./target/debug/node script.js
./target/debug/node -e 'console.log([1,2,3].reduce((a,b)=>a+b, 0))'

# run tests (parity corpus replays with no node installed)
cargo test

fusevm is pulled from crates.io with the jit, jit-disk-cache, and aot features.

License

node-js is MIT licensed — free and open source. See LICENSE.

Repository & links