A live language for microcontrollers

Talk to your board.
Watch it answer.

Writing Frothy is like having a conversation with your device. Ask it to do something, and it replies immediately. Change your mind, and try again. No compiling, no uploading, no black box.

redefine while it runs read back everything runs on ESP32s
blink.fr
New here?

What is frothy programming?

Normally, programming a microcontroller goes like this: you write code on your computer, compile it, upload it to the board, and hope. Once it's on there, the board is a sealed box — you can't ask it what it's doing.

Frothy flips that around. The board itself understands the language, so you just talk to it. Type led.on: and the light comes on. Type a new version of a word and it takes effect instantly.

It feels like p5.js — but the canvas is a real circuit.

Frothy Badge · online
A Frothy badge — a keychain-sized dev board — held between two fingers, its dot-matrix screen lit up
The big idea

Three things that make Frothy feel different.

Live

Change it
while it runs.

Redefine a word and every place that uses it picks up the new version on the spot. No build step, no re-upload — the device never stops to listen.

to blink with n [
  repeat n [
    led.toggle:; ms: 90
  ]
]
blink: 3

…then change 90 to 30 and run again. Instantly faster.

Transparent

Nothing is
hidden from you.

Ask the device words and it lists everything it knows. Ask it to see any one and it hands back the source — even on a board that was never yours.

frothy> words
led.on  led.off  blink
frothy> see blink
to blink with pin, count, wait [ ... ]

The whole device, readable, out in the open.

Readable

Read it, and
you can write it.

Name a word with to, say what it takes with, and put the steps in brackets. Drastically simpler than C, and friendly to beginners.

to pulse with pin, wait [
  gpio.high: pin;
  ms: wait;
  gpio.low: pin
]

No headers, no build flags, no datasheet to read first.

See inside

The whole device, out in the open.

frothy connect · /dev/cu.usbserial-0001
frothy> words                       -- ask what it knows
led.on  led.off  led.toggle  blink
adc.read  ms  millis  boot  ...
ok
frothy> see led.toggle              -- read any word's source
to led.toggle [ gpio.toggle: $led_builtin ]
ok
frothy> beat is fn [ led.toggle: ]  -- teach it a new word
ok
frothy> save                        -- snapshot it to flash
ok
frothy> restore                     -- revert to the last save
ok
words
Ask what it knows
Lists every word currently on the device, by name. Nothing is hidden in a binary you can't read.
see led.toggle
Read it back
Prints any word's definition the way the device stored it — even one you've never seen before.
save · restore
Keep it, or take it back
save writes your overlay to flash; restore brings the saved one back; dangerous.wipe clears it to the bare base.
A look at the language

Seven small programs.

scale.fr
to scale with percent, max [
  here bounded is clamp: percent, 0, 100;
  bounded * max / 100
]

scale: 80, 255
notes

A word is a name with code behind it — write it with to, run it with a trailing colon. with names its arguments.

here binds a value that's local to the block, so bounded exists only inside scale. A block hands back its last line — here, the scaled number.

On real hardware

Built for the messy middle.

An ESP32 development board on a workbench

Start with an ESP32.

Frothy is early, but the basic loop is already useful: flash a board, keep it powered, ask pins what they read, and redefine small words until the circuit starts making sense.

USB serial LED first ESP32 path

Change one fact at a time.

The hard part of a physical build is the messy middle — the wiring is half-right, the timing is off, and you're not sure what the sensor even returns. Frothy is good there. Leave the board powered and change it a word at a time.

  1. 01 Flash an ESP32 and open the prompt
  2. 02 Ask a pin what it reads, right now
  3. 03 Redefine a word; watch behavior change
  4. 04 save what works, and keep going
Get started

From source to a live board.

There's no package to install yet — you build the frothy CLI from source. It needs Go, and for an ESP32 a one-time toolchain fetch that takes the better part of twenty minutes. After that, flashing and connecting are quick.

  • macOS and Linux — Windows isn't supported yet
  • ESP32 development boards are the public happy path for now
  • Go 1.19+ and a C compiler; the ESP-IDF toolchain installs itself
build from source
$ git clone https://github.com/nikokozak/frothyrewrite
$ cd frothyrewrite
$ make cli            # builds the `frothy` CLI
$ frothy bootstrap    # one-time: fetch the ESP-IDF toolchain
$ frothy flash esp32_devkit_v1 --port /dev/cu.usbserial-0001
$ frothy connect --port /dev/cu.usbserial-0001
source only · pre-alpha