How Bloom Works

A journey from text to pixels on screen

When you write Bloom code and run it, a lot happens behind the scenes. This guide explains the entire journey your code takes, from the moment you type it to the moment shapes appear on your canvas.

Source Code Your .bloom file
Lexer Tokenization
Parser AST Generation
Interpreter Execution
Canvas
Deep Dives

The Big Picture

Programming languages are like translators. They take something humans can read and turn it into something a computer can execute. Bloom does this in four main stages:

1

Lexical Analysis

The Lexer reads your code character by character and groups them into meaningful chunks called tokens. It's like breaking a sentence into words.

circle(100, 50, 30)

becomes

IDENTIFIER "circle" LPAREN NUMBER 100 COMMA NUMBER 50 COMMA NUMBER 30 RPAREN
2

Parsing

The Parser takes those tokens and figures out how they relate to each other, building a tree structure called an Abstract Syntax Tree (AST).

Call
circle
100
50
30
3

Interpretation

The Interpreter walks through the AST and executes each node. When it sees a function call to circle, it draws a circle on the canvas.

Why This Matters

Understanding how a language works helps you:

Two Execution Modes

Bloom has two ways to run your code:

Tree-Walking Interpreter
Bytecode VM
Speed
Slower
Much faster
Features
All features
Most features
Error Messages
Very detailed
Less detailed
Closures
Full support
Limited
Default
Yes
No (opt-in)

The interpreter is the default because it provides better error messages for learners. The bytecode VM is available for performance-critical code.