A drawing that begins as a sentence
An L-system has an alphabet, an axiom, and production rules. The axiom is the starting string. On every iteration, all eligible symbols are replaced at the same time. Only after rewriting do we interpret the final string as drawing commands.
This parallel rewriting matters. In an ordinary step-by-step program, an earlier replacement could affect a later one in the same pass. An L-system treats every symbol as if it grows simultaneously—much like cells in a developing organism.
Alphabet: F + − [ ] · Axiom: F · Rule: F → F[+F]F[−F]FMeet the drawing turtle
The usual interpreter is a tiny imaginary turtle carrying a pen. F moves forward while drawing. + and − rotate. Brackets save and restore the turtle’s position and direction, allowing one stem to split into many branches.
Symbols can also exist only for rewriting. X, for example, may control growth but draw nothing. Separating growth symbols from drawing symbols lets a compact grammar organize complex forms.
- F — move forward and draw
- f — move forward without drawing
- + / − — turn left or right
- [ — save position and heading
- ] — restore position and heading

From one trunk to a fractal tree
Begin with F. Replace every F with a trunk plus two bracketed side branches. After one iteration you have a sapling; after four or five, thousands of repeated segments form a crown.
The self-similarity is exact in a deterministic L-system, but the picture still feels organic because branching is a familiar growth rhythm. Add small random changes to angle or length and the geometry becomes less regular while keeping the same skeleton.
Axiom F · F → FF+[+F−F−F]−[−F+F+F]
Plants are only the beginning
The same machinery can create classic space-filling and self-similar curves. The dragon curve uses two rewriting symbols and right-angle turns. The Sierpiński triangle uses recursive triangular steps. Here, the grammar describes geometry rather than biological growth.
This makes L-systems useful for learning recursion: each iteration preserves the logic of the previous one while adding detail. Complexity grows quickly, so five or six iterations can already mean tens of thousands of drawing commands.
- Dragon: X → X+YF+
- Sierpiński: F−G−G with F → F−G+F+G−F
- Koch curve: F → F+F−F−F+F

How to design and debug a rule
Start with only two iterations and a large turn angle. Check bracket balance first: every opening bracket needs a closing bracket. Then increase iterations slowly and watch string length.
If the result flies off the canvas, reduce segment length after each generation or fit the completed bounds to the viewport. If it looks like a tangled ball, lower the angle, remove a branch, or give non-drawing symbols clearer jobs.
Turn the idea into an experiment.
The quickest way to understand a pattern is to change it and watch what happens.
