Open-source project
ArhanChaudhary/NAND avatar
ArhanChaudhary/NAND

NAND builds a whole computer stack on one gate and one clock

NAND is a logic simulator suite made entirely from NAND gates

602 stars18 forksTypeScriptMIT

At a glance

What is it?
NAND is a browser based logic simulator that assembles a 16-bit computer out of NAND gates and then stacks a language, compiler, OS and IDE on top of it. Its most interesting feature is not the simulation but the two example programs that exploit the runtime to escape the virtual machine.
Who is it for?
NAND suits students and teachers who want the Nand to Tetris stack to run in a browser with the whole toolchain visible at once, and it suits people curious about what a virtual machine escape looks like when nothing checks the stack. It does not suit production work, and it does not replace a real toolchain, since every layer is a teaching implementation rather than a maintained product.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 122 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

One gate and a clock are enough to build a 16-bit machine

NAND expands its name as Not And-powered Device, and the project describes it as a Turing equivalent 16-bit computer made entirely from a clock and NAND gates emulated on the web. Everything above that level is layered on top. The listed features run from the bottom up: a CPU, a machine code language, an assembly language, an assembler, a virtual machine language, a virtual machine translator, a programming language, a compiler, an IDE and a user interface. That is the unusual part of the project. Most simulators stop at the gate level and leave the toolchain to the reader, or stop at the toolchain and assume the hardware exists. NAND claims the whole ladder. The machine is based on the Jack-VM-Hack platform specified in the Nand to Tetris course and the associated book, so the architecture, the assembly conventions and the Jack language semantics are not invented here but implemented to a published specification. The site is at nand.arhan.sh/ and the repository lists src/ and projects/ directories, along with media/ for images and a TODO.md for what remains unfinished.

Two example programs deliberately break out of the runtime

The most distinctive thing in the project is not a feature, it is a pair of exploits. The Overflow program causes a stack overflow on purpose through infinite recursion in order to perform a virtual machine escape, and it does so by leveraging the fact that there are no runtime checks preventing it. The program prints the stack pointer to the screen continuously, and once that value exceeds 2048 the stack has reached the end of its intended memory and spills into the heap, at which point the print statement malfunctions in what the documentation calls explosive fashion. Two consequences are called out. Run it on a RAM full of zeroes, which you can clear through the user interface, and the program resets itself halfway through execution without anyone pressing Reset, because the jailbroken runtime executes an instruction that sets the program counter to 0 and starts over. And if you run the GeneticAlgorithm example first, the rampaging program reads memory that was never overwritten, so the previous program's data leaks into the screen. The SecretPassword program is the other exploit, using the absence of stack smashing protection to call a function that should be inaccessible.

Undefined behaviour is documented as a feature list

The project keeps a table of contents entry for undefined behaviour, and the sub items are specific enough to be a testing checklist: operator priority, the lesser and greater than operators, the -32768 value, calling a function with too few arguments, improper type casting, stack overflows, and modifying stack frames or internal registers. There is also a section on loading your own program and one on weak type coercions, plus manual memory management and custom data types in the language guide. This documentation style is unusual and worth naming as a design decision. A runtime without checks is normally a bug report, but here it is presented as a set of behaviours you can deliberately exercise. For a classroom that means the failure modes are legible, and for a researcher it means the escape routes are reachable without patching the VM. The counterweight is that a program written for this machine is not portable. Anything relying on a stack overflow to do its job, or on weak coercion to pick a branch, will behave differently on a platform with the checks in place.

The example suite covers arithmetic, objects, recursion and memory

The bundled programs are chosen to exercise different parts of the language rather than to look impressive. Average takes a count of numbers, reads them in and prints their mean, and it is credited as coming from the Nand to Tetris software suite. It is the example that shows control flow, arithmetic, input and output and dynamic memory allocation in one place. Pong shows off the object-oriented model, with the arrow keys moving the paddle, the paddle shrinking on every bounce and the game ending when the ball reaches the bottom. 2048 is the recursion example, on a 4x4 grid moved with the arrow keys, where equal tiles merge into their sum, the 2048 tile wins the game and a full board with no legal move loses it. GeneticAlgorithm is listed among the examples as well. Six programs is a small suite, but the coverage is deliberate: I/O and allocation, objects, recursion, and then the two exploits that probe the memory model from the other direction.

Running a program means typing into the browser IDE

There is no install step to describe. NAND is reached at its homepage, nand.arhan.sh/, and the whole environment runs in the browser, so the first use is to open the page and run one of the bundled programs. The Average example is the smallest one and shows the machine doing input and output, and the documentation shows the session it produces.

txt
How many numbers? 4
Enter a number: 100
Enter a number: 42
Enter a number: 400
Enter a number: 300
The average is 210

What you should see is the prompt for a count, one prompt per number, and the computed mean at the end. That single run touches the parts of the stack an instructor would otherwise have to explain separately, since the arithmetic, the input handling and the dynamic memory allocation all happen behind those prompts.

The repository topics point at the technology underneath, and they are worth reading as an implementation note: TypeScript as the primary language, with Rust, wasm-bindgen, Vite and Svelte also appearing, plus SCSS for styling. A Rust core compiled to WebAssembly with wasm-bindgen as the bridge, a Svelte frontend built by Vite, is a plausible reading of that list, though the project documentation does not spell out the division of labour between the simulator core and the interface. Practically, the consequence for a user is that there is nothing to install and no offline mode described, so the machine is available wherever the page loads. For an instructor the appeal is the flip side: a student needs a browser, not a toolchain, and the same URL serves the IDE, the compiler and the examples. The repository also carries a .vscode/ directory, a .github/ directory, an .imgbotconfig and a TODO.md, which is what a small project with an active issue list looks like on disk.

No releases, one author, and a scope that is a teaching artefact

The repository has no GitHub releases, so there is no versioned artefact to download and no changelog to track. The last push to the main branch was on 2026-06-24 and the repository is not archived, so the code has been worked on within the last few months, but the maintenance relationship is one person with a TODO list rather than a project with a release cadence. That is a reasonable shape for a project whose stated purpose is education, and it sets the ceiling on expectations. The licence is MIT, which allows reuse and modification with the notice retained and no warranty attached, so an instructor can adapt the language guide or the IDE for a course without licence friction. The Jack OS reference in the documentation is organised around the standard API surface: Array, Keyboard, Math, Memory, Output, Screen, String, Sys and Error Codes, and there is a section on going beyond the Jack OS. What the project is not is a general purpose emulator of the Nand to Tetris platform for people who want to run their own .asm files against a reference implementation, since the emphasis is on the integrated, in-browser experience.

Editorial conclusion

NAND suits students and teachers who want the Nand to Tetris stack to run in a browser with the whole toolchain visible at once, and it suits people curious about what a virtual machine escape looks like when nothing checks the stack. It does not suit production work, and it does not replace a real toolchain, since every layer is a teaching implementation rather than a maintained product. Before adopting it for teaching, open https://nand.arhan.sh/ and run the Overflow example to see the runtime misbehave, read the documented list of undefined behaviours, and check the source tree under src/ and projects/ to see how much of the toolchain is implemented in the repository rather than assumed.

Frequently asked questions

What is the NAND project?

NAND is a web based logic simulator suite described as a Turing equivalent 16-bit computer made entirely from a clock and NAND gates, complete with its own CPU, assembler, compiler, operating system and IDE.

How do I run NAND?

The project has no install step. You open the site at nand.arhan.sh/, where the simulated machine, the compiler and the example programs are all available in the browser.

What does the Overflow example program in NAND do?

It deliberately triggers a stack overflow through infinite recursion to perform a virtual machine escape, relying on the absence of runtime stack checks. Once the stack pointer exceeds 2048 the stack spills into heap memory and the output becomes corrupted.

Which programming language does NAND use?

The project provides its own machine code, assembly, virtual machine language and high level language, based on the Jack-VM-Hack platform specified in the Nand to Tetris course and its associated book.

Can I write my own programs for the NAND machine?

Yes. The documentation includes a section on loading your own program, along with language guidance on custom data types, weak type coercions and manual memory management.

Official sources

  1. ArhanChaudhary/NAND on GitHub
  2. Issues
  3. License: MIT
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/arhanchaudhary-nand.svg)](https://hysenlabs.com/projects/arhanchaudhary-nand)

Was this useful?