The Biologist Who Wrote Plants
In 1968, a Hungarian biologist named Aristid Lindenmayer published a paper nobody in computer science was initially watching. His interest was not in rendering or animation. He wanted to formalize the way biological cells duplicate and speciate during development, specifically, the filamentous algae he studied in his Utrecht laboratory.
What he produced was not a biological theorem. It was a formal grammar. A rewriting system whose output, when run through a geometric interpreter, looked precisely like the organism he was trying to model. He had accidentally invented a machine that could write flora.
This mechanism is now called an L-System, short for Lindenmayer System. The formalism is ruthlessly simple: a handful of letters, a handful of substitution rules, and a number of repetitions. The complexity that accumulates from that simplicity is botanical, fractal, and formally infinite.
2. Production Rules: Text Before Drawing
An L-System has three components: an alphabet of symbols, an axiom (the starting string), and a set of production rules that substitute each symbol simultaneously with every application.
Consider the simplest non-trivial example. The alphabet is {A, B}, the axiom is A, and there are two rules:
Applied once: A becomes AB. Applied twice: AB becomes ABA. Applied three times: ABA becomes ABAAB. The lengths grow as Fibonacci numbers. No drawing involved, just string rewriting. The geometry comes later.
Now consider the first rule that produces visible geometry. The Koch Snowflake:
- Axiom:
F--F--F - Rule:
At depth 0, the string is F--F--F, a triangle. At depth 1, each F expands into F+F--F+F. At depth 2, each of those Fs expands again. The string grows exponentially. No pixel has been placed. The shape exists only as text.
This is the key insight Lindenmayer offered: form is latent in grammar. Before the drawing begins, the structure is complete. The interpreter merely reveals it.
F, Move forward, draw segmentG, Move forward, no draw+, Rotate left by angle δ-, Rotate right by angle δ[, Push state onto stack (save position and angle)], Pop state from stack (return to saved position)X, Placeholder (no geometric meaning, drives expansion)
3. The Turtle Interpreter
The geometric interpreter for an L-System borrows from Logo's "turtle graphics", a concept developed at MIT in 1967. A turtle sits at a point in space, facing a direction. It understands two instructions: move forward a fixed distance, and rotate by a fixed angle.
To draw an L-System, the turtle reads the final string character by character. F moves it forward and draws. + and - rotate it. The square brackets implement a stack, the mechanical equivalent of a branch: push your current state, walk the branch, pop back to the fork and continue.
// The complete turtle interpreter, compacted
function drawLSystem(ctx, sentence, angle, stepLen) {
let x = 0, y = 0, dir = -90; // start pointing up
const stack = [];
for (const ch of sentence) {
if (ch === 'F') {
const rad = (dir * Math.PI) / 180;
const nx = x + Math.cos(rad) * stepLen;
const ny = y + Math.sin(rad) * stepLen;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(nx, ny);
ctx.stroke();
x = nx; y = ny;
} else if (ch === '+') { dir += angle; }
else if (ch === '-') { dir -= angle; }
else if (ch === '[') { stack.push({ x, y, dir }); }
else if (ch === ']') {
({ x, y, dir } = stack.pop()); // return to branch fork
}
}
}
This is the entirety of the interpreter. The grammar does everything else. The same loop, given different strings, produces a snowflake, a tree, or a fern, the difference lives entirely in the production rules.
4. From Snowflake to Fern
I. Koch Snowflake (angle 60°)
The Koch curve emerges from a single rule applied to an equilateral triangle. Each straight segment is replaced by four segments that jut outward at 60°. At depth 4, the perimeter is fractal: finite area, theoretically infinite boundary.
The resulting string at depth 2 contains Fs separated by structured turns. The snowflake emerges not from drawing a special shape, but from a rule that has no knowledge of its own visual consequence.
II. Binary Tree (angle 25°)
The substitution rules now involve two alphabets, one that draws, one that doesn't, and the bracket operators that encode branching topology. Each 0 is a leaf that eventually becomes a node. Each 1 is a structural segment:
The brackets are the breakthrough. Before them, an L-System could only produce linear chains. The push/pop stack lets it simulate the recursive branching structure that characterizes every real vascular plant.
III. Barnsley Fern (angle 25°)
The canonical generative fern requires four rules and two alphabets. X is a pure expansion driver, it draws nothing directly. F draws segments. At depth 5 or 6, the output is indistinguishable from a scanned leaf:
Lindenmayer's original insight is fully present here: the rule does not say "draw a fern." The rule says how a cell substitutes itself. The fern is a consequence of the combinatorics of that substitution, not an intention baked into any single line.
5. The Generative Lab
Modify the axiom and production rules below. Adjust depth and branching angle. Every combination generates a unique organism, the interpreter has no opinion on what it draws.
Morphogenesis Without an Author
What Lindenmayer formalized in 1968 was not an algorithm for making plants look like plants. It was evidence that the visual complexity of biological form is a consequence of recursive rule application, not design, not intention, not intelligence.
The generative artist who uses L-Systems occupies a strange position: author of the rules, but not the output. The grammar is written in minutes. The plant it produces is not anticipated. The surprise is structural, it belongs to the combinatorics of the substitution, not to any explicit creative decision.
That gap between rule and consequence is where generative art lives.
The Coding Train: Daniel Shiffman builds L-System fractal trees step by step in p5.js — a direct implementation of the concepts covered in this article.
Sources & Further Reading
- [1] Lindenmayer, A. (1968). Mathematical models for cellular interaction in development. Journal of Theoretical Biology, 18(3), 280–315. doi:10.1016/0022-5193(68)90079-9 (The original 1968 paper.)
- [2] Prusinkiewicz, P. & Lindenmayer, A. (1990). The Algorithmic Beauty of Plants. Springer-Verlag. ISBN 978-0-387-97297-8. Free PDF: algorithmicbotany.org
- [3] Prusinkiewicz, P. & Hanan, J. (1989). Lindenmayer Systems, Fractals, and Plants. Lecture Notes in Biomathematics, Vol. 79. Springer. ISBN 978-0-387-97092-9.
- [4] Mandelbrot, B. (1982). The Fractal Geometry of Nature. W.H. Freeman. ISBN 978-0-7167-1186-5. (Contextual framework for recursive biological geometry.)
- [5] Abelson, H. & diSessa, A. (1981). Turtle Geometry: The Computer as a Medium for Exploring Mathematics. MIT Press. ISBN 978-0-262-51037-3.
- [6] Shiffman, D. (2012). The Nature of Code: Simulating Natural Systems with Processing. Self-published. Chapter 8: Fractals. natureofcode.com
- [7] Hofstadter, D.R. (1979). Gödel, Escher, Bach: An Eternal Golden Braid. Basic Books. (Chapters on formal systems, string rewriting, and self-reference.) ISBN 978-0-465-02656-2.
- [8] Glassner, A. (1990). Graphics Gems. Academic Press. (Relevant chapter on turtle geometry rendering and branching systems.)
- [9] Barnsley, M. (1988). Fractals Everywhere. Academic Press. ISBN 978-0-12-079062-7. (Iterated function systems and their relationship to plant morphology.)
- [10] University of Calgary Biological Modeling Group. (ongoing). The Algorithmic Botany project. algorithmicbotany.org (Prusinkiewicz's research lab, open access papers and L-System tools.)