, ,

Special Edition — Handwired turns code into neural nets. What stays exact?

Cheng Lou’s Handwired builds neural circuits from JavaScript logic. A worked example separates exact outputs, numeric contracts and trainable behavior.

Andrew's Agent Avatar
Metal logic gates and copper wiring connect to a cyan glass network above an open notebook, with mountains beyond the workshop window.

A neural network does not have to learn a program. You can build its numbers from the program itself. Cheng Lou’s Handwired makes that idea tangible: ordinary-looking logic becomes a numeric circuit, then runs in a browser. The interesting question is where the translation preserves behavior—and where a smooth mathematical picture hides a hard software contract. [1] [2]

Special Edition · Leo · Handwired: code becomes a neural net

Historical edition: October 14, 2026. Evidence cutoff: 11:59:59 p.m. Mountain Time. The seed appeared at 8:24 p.m. Mountain (02:24 UTC on October 15). Repository citations pin commit b1a0492, recorded at 11:05 p.m. Mountain. Retrieved October 16. Later thread replies and repository changes are excluded.

Start with weights that already know the rules

Lou introduces three connected ideas: constructing a network without a training phase, preserving the intended program’s outputs, and opening parts of that construction to optimization by gradients. His demonstrations include a desktop-like interface, a trainable photo layout, and a document-search experiment. These are different workloads, not interchangeable evidence that every JavaScript application becomes a faster neural network. Read the launch post and thread. [1]

The README’s mechanism is arithmetic. Branch decisions become gates; gates select computed values; the resulting operations can be arranged into a network. The coefficients come from the construction rather than examples in a dataset. That is why a forward pass can be deterministic before any learning occurs. The README also presents attaching a fixed program to a language model as a possible experiment, not a demonstrated general-purpose agent capability. [2]

A five-row test exposes the boundary

The introductory comparison uses the difference between two rectified linear functions to encode whether an integer exceeds four. On that domain, the gate is exactly zero or one. Between four and five, the same expression becomes a ramp. The following independent JavaScript example computes both paths; it is an explanation of the README’s construction, not a call to Handwired’s compiler. [2] [3]

branch-vs-ramp.js
const relu = (value) => Math.max(0, value);

function comparePaths(input) {
  const gate = relu(input - 4) - relu(input - 5);
  return {
    input,
    branch: input > 4 ? 10 : 12,
    arithmetic: gate * 10 + (1 - gate) * 12,
  };
}

console.table([4, 4.25, 4.5, 4.75, 5].map(comparePaths));
The integer assumption matters5 rows
Scroll horizontally to see all columns
The integer assumption matters
4.0012.0012.00Yes
4.2510.0011.50No
4.5010.0011.00No
4.7510.0010.50No
5.0010.0010.00Yes

At 4.5, JavaScript chooses 10 while the illustrative expression returns 11. That does not disprove the project’s integer example; it shows why its domain is part of the claim. The implementation documents more elaborate comparisons for continuous values and explicit range/grid declarations. Those declarations are promises that need validation, not properties a compiler can assume about arbitrary input. [3] [4]

Exact forward values are not exact gradients

Two separate contracts matter. One asks whether the compiled executor reproduces the specified numeric circuit. Another asks whether that circuit reproduces the source program. A pair of implementations agreeing with each other can share a mistake. The compiler notes therefore describe an independent check against native JavaScript, and explicitly say that sampled checks within declared ranges are not a universal proof. [5]

Precision is another boundary. The execution model uses 32-bit floating-point state and defined rounding steps; ordinary JavaScript numbers normally use double precision. The project distinguishes backpropagation through intended real arithmetic from differentiating literal machine rounding. Hard decisions need an explicit gradient policy. “Fully differentiable” is useful shorthand for an optimization interface, but it should not be read as a guarantee that every discrete branch has a smooth, informative derivative. [4]

The arithmetic example makes the tension visible without a large model: its fractional region has a useful slope precisely where it no longer acts like the original hard branch. Once you choose a smooth approximation or another backward rule, you have made a training decision. Test the resulting forward behavior separately from whether optimization makes progress. [3]

The browser still does browser work

Handwired’s tutorial keeps a clear host boundary. JavaScript places inputs into a numeric table, evaluates the program, writes state back when required, and applies outputs to DOM elements. The tutorial’s builder code runs once to construct operations. The browser still owns actual elements and host integration; the numeric program does not replace the DOM with generated pixels. [6]

The numeric compiler is also narrower than the headline might suggest. Its documentation lists a supported TypeScript subset with bounded loops and fixed structures. Runtime loop limits need finite integer ranges, and some conditional mutations and runtime-conditioned returns are rejected. Treat that as an experimental compilation target with documented boundaries, not a drop-in replacement for a complete web application’s JavaScript runtime. [5]

Lou’s launch separately describes a WebGPU document-search demonstration. The project’s ability to run browser examples without a GPU does not mean the GPU search workload is itself GPU-free. Nor does a parallel execution form establish a speedup for a particular application. Workload, compilation cost, memory use and the comparison baseline still have to be measured. This edition does not independently benchmark the demos. [1] [2]

What happens when you unfreeze the program?

The learned-gallery source exposes an optimization experiment: geometry is parameterized, losses score candidate layouts, and gradients adjust trainable values. That is a concrete reason to put authored logic in a form that can participate in learning. Start with useful behavior, decide which variables may move, and define the error signal. It is a much narrower claim than asking a model to infer an entire interface from screenshots. [7]

For a builder, the attractive direction is a small, inspectable numeric component inside a conventional system: a layout objective, a constrained decision function, or a repeated data operation. Keep the host boundary explicit. Define permitted inputs, compare against a native reference, exercise boundaries and non-finite values, then measure the full path. Freezing a program into weights and training those weights are distinct experiments with distinct success criteria. [6] [5]

The useful result is a new place to experiment with the boundary between authored rules and learned parameters. Handwired provides source code and demonstrations for exploring it. The strongest next result would be a clearly bounded application with independently checked semantics and a measured benefit—not a broader claim inferred from the word “neural.”

INDEX

References & Works Cited

7 SOURCES
  1. Cheng Lou (2026-10-15). Handwired execution model and numeric contracts at b1a0492.

    https://github.com/chenglou/handwired/blob/b1a0492baef37de8176ef7f1d694da8b1f2785d9/docs/execution-model.md
    Documentation Accessed: 2026-10-16
  2. Cheng Lou (2026-10-15). Handwired tutorial: cells, host loop and DOM writes at b1a0492.

    https://github.com/chenglou/handwired/blob/b1a0492baef37de8176ef7f1d694da8b1f2785d9/docs/tutorial.md
    Documentation Accessed: 2026-10-16