Vibeleaderboard
Index / tool

Handwired

chenglou.me
Category
Developer Tools
Rank

Previous survey · No. 986 ·

Pricing
Open Source
Type
TOOL
Use case
Models: Train & Run
Date

About

Handwired transforms regular JavaScript control flow into matrix multiplication and ReLU-style operations over floats, producing a neural net with hand-written weights and no training. Because the result is fully differentiable, the weights can be unfrozen and trained, and it can run in JS or on WebGPU. Demos include a mini OS and a search over 100,000 JSON documents.

What it does

A TypeScript toolkit for building interactive programs as fixed arithmetic circuits. You write setup code that runs once and appends steps, mostly weighted sums and gated products over 32-bit floats, to a circuit object. The finished program never branches or loops at runtime: every comparison, choice and spring animation becomes arithmetic, and a small host loop writes browser inputs into a table, evaluates, and pushes outputs to the page. Because only two simple primitives are used, gradients can flow through the whole thing. The docs say plainly that nothing converts existing source automatically; you rewrite logic by hand.

Why it's ranked here

This is a research project with unusually honest engineering behind it, not a library to ship with. The author documents exact rounding rules, the cost of each construction in operations and layers, and measured evaluation times for the flagship desktop demo. The starter app is tested frame by frame against a plain version of the same switch, and the runtime is checked against a reference evaluator. MIT licensed. The catch is a gap between the headline and the docs: the front page says it turns your code into a neural net, while the reference docs state no such conversion exists.

What's good

Correctness is treated as a contract. Every declared range, grid and one-hot group is a promise the builder relies on, and evaluation rejects a table that breaks one, so a pointer coordinate off its grid throws with the cell name. The docs quantify tradeoffs instead of hand-waving: a comparison on declared grids costs 2 operations versus 15 without. Animation design is thought through, with springs stepped to each event's timestamp so stored state stays bit-identical across frame rates. The tutorial walks one toggle switch end to end.

Tradeoffs

You cannot feed it ordinary code; every conditional and loop must be rewritten as counts, tables or selects, since the program runs every operation every frame and cannot stop early. Only the search demo runs on WebGPU; everything else evaluates on the CPU in JavaScript. Large programs are expensive to build: the docs report millions of operations taking seconds and several gigabytes of memory. The package is marked private with no published install, the toolchain assumes Bun, and much of the experimental history is described as a lab you can ignore.

How to use it well

Treat it as a place to study how program logic maps onto neural-network style arithmetic, or to experiment with training the weights of an exact program. Clone the repository, run the toggle template, then copy that folder to start your own app, following the tutorial. Declare every input range and grid up front so comparisons stay cheap. Always keep a plain JavaScript version alongside and compare the two, as the template does, because agreement between evaluators does not prove the circuit matches your intent. It is not a production UI framework.

Technical notes+

docs/README.md places the Circuit class, builder macros, compiler and evaluators in one core runtime module; four instruction kinds: affine, reglu (f(left * max(0, gate))), boolean rounding via the 8_388_609 add/subtract trick, and indexRead, all rounded with Math.fround (docs/execution-model.md). Compilation layers instructions by dependency depth; recomputeDepths is opt-in. template/toggle.ts declares cells with input/stateBit/event, builds hit tests with emitCompare and emitSelect, animates with emitAnimatedObject, and drives frames through advanceFrame with 'events and settle checks'. template/toggle.test.ts asserts thumb error under 1e-5 against toggle-reference and that an off-grid coordinate throws. package.json is private, MIT, Bun scripts only; scripts/check.ts runs tsc and oxlint 8 at a time. lab/status.md logs HandwiredOS operation counts and timings.

Observed

License
MIT (LICENSE, package.json)
Language
TypeScript, run with Bun (package.json, docs/README.md)
Packaging
package.json marked private; no published package, clone and run
Interface
Library of builder functions plus a host loop; no CLI or source converter (docs/README.md)
Execution backends
CPU JavaScript evaluator; WebGPU only in the JSON search demo (docs/README.md)
Tests
Template compared frame by frame with a plain JavaScript reference (template/toggle.test.ts)
Tooling
tsc type-check and oxlint lint via one check script (scripts/check.ts)

Read from README.md, package.json, LICENSE, docs/README.md, docs/execution-model.md, docs/behavior-choices.md, docs/tutorial.md, template/README.md, template/main.ts, template/toggle.ts, template/toggle.test.ts, lab/status.md, scripts/check.ts.

Similar tools

Browse all tools →

Tags

javascriptneural-netwebgpudifferentiablecompilerresearch

Tech Stack

Node.jsTypeScript

Editorially curated, with community endorsements as a secondary signal. Corrections welcome.