esolang

Nandcode

One operation, NAND, and every other gate built out of it.

Benjamin F. Berger, 2026 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 14 known programs · Test method

Run it

Expected: 1

The idea

Benjamin F. Berger made Nandcode in 2026. Its only logic is NAND, which gives 0 when both bits are 1 and 1 otherwise. NOT, AND, OR and XOR all have to be built from it, one line at a time. The specification says the whole machine lives in one 64-bit CPU register. Bits 0 and 1 are reserved, so a program has at most 62 variables.

Read the story

There is no jump and no loop. A program runs once from top to bottom, so it always halts, and the specification calls it not Turing complete.

The machine

LineDoes
in: x yRead the inputs, one bit each
v = aCopy a bit
v = a !& bSet v to a NAND b; a nand b is the same
out: x yPrint the outputs

An operand is a variable or one of true, 1, false and 0. The specification leaves the input and output open. The inputs are the characters 0 and 1 of the input, and out: prints each bit with nothing between them.

Example

XOR takes four NANDs.

XOR takes four NANDs.

The swap needs a third variable.

Expected: 01

AND is a NAND followed by a NOT, and NOT is the NAND of a bit with itself.

Expected: 1

Further

Also in Turing tarpits

Write your own in Run Convert a program from Nandcode

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: nandcode.

Command line

shib run nandcode -e 'in: x
x = x !& x
out: x' --input '0'
shib manual nandcode

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/nandcode.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org