What is Handwired?

Handwired is an open-source project that turns ordinary JavaScript into a neural network. Cheng Lou, a programmer whose GitHub profile lists work on React, ReasonML, ReScript, Messenger and Midjourney, and who wrote the react-motion animation library and the pretext text-layout library, introduced it on X on 15 October 2026 as “my latest toy project,” with three claims: no training, exact outputs compared with the JavaScript program, and full differentiability, all runnable in a browser without a GPU.

The code is on GitHub under the MIT license, and a demo site hosts three interactive examples. The public repository was created that morning, but its documentation records experiments going back to at least September 2026, with measured results, known issues and parked ideas kept in a running status page.

How does code become a neural net?

The README starts with a ternary. The line result = (a > 4) ? 10 : 12 can be written as arithmetic: above4 = max(0, a − 4) − max(0, a − 5), which is 1 when an integer a is above 4 and 0 otherwise, and then result = above4 × 10 + (1 − above4) × 12. Both branches are computed and the bit picks one. Max(0, x) is ReLU, the activation function used throughout neural networks, so the branch has become a tiny network.

Handwired does this for whole programs. Its tutorial describes two operations: affine, a weighted sum of earlier values plus a bias, and reglu, which multiplies one weighted sum by the ReLU of another. Every step rounds to 32-bit floats. Builder code, which is ordinary JavaScript, runs once and appends these operations to a circuit, so nothing in the finished program branches or loops at runtime. Handwired then collects the operations into layers and runs them as matrix multiplications.

The program reads and writes a table of numbers. Browser inputs such as pointer coordinates go in, and next-state values and outputs come out, which the page writes to the DOM. Each cell is declared with a range and sometimes a grid, such as pointer positions on a 1/64-pixel grid, and the evaluator throws an error when a value leaves its declared range. A loop over a runtime-sized list becomes a count, a tree, a table, or the same work on every item, since the program always runs every operation.

Why “exact” and “differentiable” both matter

Exactness means the network is a faithful copy of the code, not an approximation trained to imitate it. The tutorial says decisions match exactly, because Handwired’s comparisons return the same bits as JavaScript’s for every declared value, while continuous quantities computed in 32-bit arithmetic, such as spring animations, match within a tolerance. The template’s test runs a toggle switch and its plain JavaScript twin over a scripted trace of 138 frames and requires the on and armed bits to match exactly and the thumb position within 1e-5 pixels.

Differentiability is what makes it more than a curiosity. Since the program is only sums, products and ReLUs, gradients flow through all of it. The README lists the possibilities: unfreeze the weights and train them, attach a frozen program to a generic neural net and train the combination end to end, or get GPU-level parallelism from code written in a single-threaded style. If the difference between writing weights and learning them is fuzzy, our explainer on training versus inference covers the basics.

The three demos

The Mini OS, called HandwiredOS in the repository, is a small desktop with Monitor, Notes and Photos windows and a dock. One compiled program handles focus, stacking, dragging, resizing, window controls, springs, the photo layout and a list of the program’s own numbers, rendering to regular DOM. As of 14 October it had 234 source cells, 4,646 live operations in 130 layers and 9,909 stored weights, every one written by builder code and none trained.

The learned gallery shows the trainable side. A small network, two ReGLU layers of six units, lays out photos for 20 slots, and its coefficients are cells of the program. As you drag rectangles in a sketch, the page trains those coefficients with the Adam optimiser in real time, using gradients from Handwired’s own backpropagation, until the photos match the sketch. It is a small, visible example of changing a model’s behaviour with examples, applied to a program that started out hand-wired.

The third demo searches 100,000 generated JSON documents at every keystroke. A JSON highlighter and a regex matcher, written mostly as normal code, were compiled into WebGPU compute shaders. According to the project’s measurements, the highlighter validates 100,000 documents already on the GPU in about 2.2 ms, and a search on the page takes 12 to 15 ms. Every value returned from the GPU was checked against a CPU result, and none differed.

How to try it

The quickest way is the demo site, which runs in a normal browser. To build on it, clone the repository, run bun install and bun start to serve the demos locally; the repository needs the Bun runtime and its tests were last run with Bun 1.4.3. A template folder contains a toggle switch written as one numeric program and checked against the same switch in plain JavaScript, which the tutorial suggests copying to start a new app.

Expect to write builder code rather than drop in an existing script. Handwired is not a converter that takes any JavaScript file: you declare cells with ranges and build the program with helper functions for comparisons, selections, table reads and springs. The documentation is long and precise, with separate guides for single expressions, loop patterns, behaviour choices and the execution model.

Why this is interesting for AI

Compiling programs into network weights is not new in research. DeepMind’s Tracr compiled programs written in the RASP language into transformer weights in 2023, mainly as a testbed for interpretability. Handwired takes a more practical, front-end angle: everyday interface code, run at interactive speeds in a browser, with exact checks against the original.

That opens two ideas that interest AI developers. One is hybrid systems. Lou suggested on X attaching a specific Handwired program to a small language model such as nanoGPT, so a model could “speak both Shakespeare and that exact specific JavaScript program.” The other is hardware: once code is matrix math, it can in principle ride on the GPU tooling built to run neural networks, such as the on-device inference engine Google open-sourced as ML Drift, rather than needing hand-written parallel code.

Limits: a toy project with real constraints

Lou calls Handwired a toy, and the project’s own status page is candid about limits. The GPU only pays off with many independent inputs: one JSON document takes about 80 microseconds for the highlighter on the CPU, while a round trip to the GPU alone takes 0.6 ms or more. In a September measurement, HandwiredOS took 2.2 ms per evaluation on WebGPU against 81 microseconds on the CPU in Bun, and its 6.4 MB shader did not finish compiling in Metal after 28 minutes until it was split.

There are structural limits too. A program cannot loop a runtime number of times, so loops have to be rewritten as fixed structures, every operation runs on every evaluation, and values must stay inside declared ranges. Training a hand-wired program can change what it does, which is the fun of the learned gallery and also a reason to keep tests. We have not run the code ourselves; the figures here are the project’s own measurements.

Common questions

Does Handwired train a neural network to copy my code?

No. It writes the weights directly from the program’s logic, so no training is needed and decisions match the JavaScript exactly. You can train the weights afterwards if you want to.

Does Handwired need a GPU?

No. Programs run on the CPU in JavaScript in a normal browser. The JSON search demo uses WebGPU to search 100,000 documents in parallel.

Is Handwired open source?

Yes. The code is on GitHub at chenglou/handwired under the MIT license, with a tutorial, a template app and three demos.

Sources & further reading

  1. Handwired: turn your regular JavaScript code into a neural net ↗
  2. chenglou/handwired README and docs ↗
  3. The JSON highlighter and regex search over many documents on the GPU ↗
  4. Handwired lab status ↗
  5. Tracr: Compiled Transformers as a Laboratory for Interpretability ↗
How this story was made

Written by Kristian Kostov with AI assistance and checked against the linked sources. Company performance claims are attributed to the company. Analysis reflects AiLookout’s interpretation; we have not independently tested the products discussed. Cover photography is illustrative and does not depict the specific announcement or product.

Our editorial standards
Back to all stories