
Most programming languages look like walls of text — brackets, semicolons, and keywords stacked line after line. But imagine writing a program that looks like a piece of abstract art, made entirely of colored blocks arranged like a painting. That’s exactly what the piet programming language offers. It’s one of the most unusual entries in the world of esoteric programming languages, turning the act of coding into something closer to visual composition than traditional software development. In this guide, we’ll explore what the piet programming language is, how it works, why it was created, and walk through a hands-on piet programming language example. We’ll also break down the famous piet programming language hello world output — a rite of passage for anyone experimenting with this unusual language — and look at the tools you can use to try it yourself. What Is the Piet Programming Language? The piet programming language is an esoteric programming language created by David Morgan-Mar in 2001. It’s named after the Dutch painter Piet Mondrian, known for his abstract paintings built from blocks of primary colors separated by black lines. That artistic inspiration isn’t just a naming gimmick — it’s baked directly into how programs are written. A program written in the piet programming language isn’t a text file at all. It’s a PNG image made up of colored blocks, and the interpreter reads that image the same way a traditional compiler reads source code. Esoteric programming languages, often called “esolangs,” are designed less for practical software development and more to explore unconventional ideas about computation, syntax, and creativity. Some esolangs push the limits of minimalism (like Brainfuck), while others push the limits of visual or conceptual novelty. The piet programming language sits firmly in the second category — it asks the question, “What if source code could be art?” Because of this, the piet programming language has become a favorite among hobbyist programmers, computer science students, and digital artists who enjoy the challenge of writing functional code that also happens to be visually striking. It’s not something you’d use to build a production application, but it’s an excellent way to deepen your understanding of stack-based computation, control flow, and even color theory. How Does Piet Programming Language Work? To understand how the piet programming language works, you first need to let go of the assumption that “code” has to be text. In Piet, a program is a bitmap image. The image is divided into blocks of contiguous, uniformly colored pixels, and it’s the relationships between these color blocks — not the colors themselves in isolation — that define what the program actually does. Here’s the basic mental model: This means that in the piet programming language, computation is essentially a journey across a colored canvas. The interpreter moves from block to block, and every transition between colors is a coded instruction. It’s a completely different way of thinking about programming — instead of reading a sequence of commands top to bottom, you’re tracing a path through a mosaic. This design also means that two Piet programs that perform the exact same function can look completely different visually, since there’s enormous freedom in how you lay out the colored blocks. That flexibility is part of what makes the piet programming language such a fun creative outlet — programmers can add hidden imagery or aesthetic flourishes without breaking functionality, as long as the core color relationships stay correct. Also Read: If you enjoyed exploring the piet programming language, you’ll also love our deep dive into the Hare programming language, another unique language built for simplicity and control. Key Components of a Piet Program Before you can read or write a piet programming language example, you need to understand a few core building blocks that make up the language’s architecture. Codels A “codel” (short for “color pixel block”) is the fundamental unit of a Piet program, similar to a pixel in a normal image but treated as a functional unit of code. A codel isn’t necessarily a single pixel — it can be a larger block, since Piet interpreters let you define a “codel size” (for example, 1 codel = 5×5 real pixels), which makes it easier to design and read the program visually. Larger codel sizes essentially “zoom in” on the image, making the color blocks bigger and easier to distinguish. The Color Palette The piet programming language uses a specific palette of 20 colors: 18 “hue and lightness” combinations plus black and white. The 18 core colors are built from six hues (red, yellow, green, cyan, blue, and magenta) at three lightness levels (light, normal, and dark). Black and white serve special structural purposes rather than representing operations themselves. When the interpreter moves from one color block to an adjacent one, it calculates the difference in hue (how many steps around the six-hue color wheel) and the difference in lightness (how many steps between the three lightness levels). That specific combination of hue-change and lightness-change tells the interpreter which operation to perform — whether that’s pushing a value, adding two numbers, duplicating a value, or printing output. Direction Pointer (DP) and Codel Chooser (CC) Two internal “pointers” guide how the interpreter moves through the image: Together, these two pointers let the interpreter navigate the image, even when a color block has multiple possible exits. When the interpreter hits a wall (a black block or the image boundary), it uses a defined algorithm to rotate the DP and/or toggle the CC to try to find a new path forward. Stack-Based Execution Like many esoteric and low-level languages, the piet programming language uses a stack-based model for execution. Values are pushed onto the stack, popped off, added, multiplied, duplicated, and manipulated using standard stack operations. If you’ve ever worked with Forth, PostScript, or Reverse Polish Notation, this part of Piet’s underlying logic will feel familiar — the visual color-block mechanism is really just an unusual “front end” for a fairly conventional stack-based virtual machine underneath. Piet Programming








