GitHub - mlajtos/fluent: tiny lang for differentiable tensors and reactive programming

3 min read Original article โ†—

Learnable math. A small language where math reads the way you read โ€” left to right, no tables to memorize. Learn the whole thing in five minutes, right in a browser tab.

Take the tour โ€” fifteen interactive rooms, from 1 + 2 to a value that finds โˆš42 on its own. Or just open the playground and type.

Fluent is the working end of New Kind of Paper, an essay series about what math could feel like if pen, paper, and calculator were one instrument (part two, three, four, five).

Example gallery

demo
๐ŸŒ€ Mandelbrot โ€” the Mandelbrot set over the whole plane, sharper as you drag the depth โ–ถ run
๐Ÿฆ  Game of Life โ€” Conway's Game of Life on a large grid โ–ถ run
๐Ÿ”ฎ The Name Dreamer โ€” a small transformer that invents new names from a word list โ–ถ run
๐Ÿฆ Combinators โ€” combine functions without naming their arguments โ–ถ run
๐Ÿ“ท Live edge detection โ€” your webcam, edge-detected in real time โ–ถ run
๐ŸŽต Live spectrum โ€” your microphone's frequency spectrum, live โ–ถ run
๐ŸŽธ Pitch detector โ€” the pitch of a note you hum โ–ถ run
๐Ÿ“ˆ Linear regression โ€” a line fit to points by gradient descent โ–ถ run
๐Ÿ” Touch the loss landscape โ€” a ball you roll downhill on a loss surface โ–ถ run
โš”๏ธ adam vs sgd โ€” two optimizers descending the same surface from the same start โ–ถ run
๐ŸŒธ Reactionโ€“diffusion โ€” two reacting chemicals that settle into spots and stripes โ–ถ run
๐Ÿ”ฌ Lenia โ€” smooth, continuous cellular automata โ–ถ run
๐Ÿงฒ Spinning magnets โ€” an animated vector field โ–ถ run

More in the playground: press Ctrl+O for the full gallery.

the names, at a glance
glyph word full name
โˆ‡ grad TensorGradient
ฮฃ sum TensorSum
ฮ  prod TensorProduct
ฮผ mean TensorMean
โŒˆ ceil TensorCeil
โŒŠ floor TensorFloor
โ€” max TensorMax
โ€” min TensorMin
# length TensorLength
_ gather TensorGather
โด reshape TensorReshape
..< range TensorRange
... โ€” TensorRangeInclusive
โŠ— outer TensorOuter
^ pow TensorPower
โˆš root TensorRoot
% mod TensorRemainder
รท div TensorDivide
ร— mul TensorMultiply
~ var TensorVariable
:= โ€” TensorAssign
โŸณ iter FunctionIterate
โฃ โ€” FunctionPower
. apply FunctionApply
@ eval FunctionEvaluate
$ โ€” Reactive
โ€” watch TensorWatch
โ€” conv TensorConvolution
โ€” once SignalOnce

Some cells are still empty โ€” the language is young, and names are earned.

IDE

Live evaluation on every keystroke, hover docs, unicode completion (type alpha, get ฮฑ), syntax trees for quoted code, camera and microphone as tensor sources, and LLM code generation โ€” write ;;a bouncing ball;; and it appears (bring your own Anthropic API key, set via the command palette). Hover any built-in for its doc card, or open the built-in Documentation for the reference.

Ctrl+O examples ยท Ctrl+S share as URL ยท Ctrl+P commands ยท Ctrl+Space complete โ€” Safari reserves โŒ˜O, use โ‡งโŒ˜O there

Run locally

git clone https://github.com/mlajtos/fluent.git
cd fluent && bun install
bun dev   # โ†’ http://localhost:3000

The whole thing fits in a handful of files โ€” read it, change it:

file what
language.ts the language โ€” grammar (Ohm), evaluator, prelude; tensors via jax-js, reactivity via preact signals
client.tsx the IDE โ€” components, visualizers, Monaco editor, playground
tour.ts the tour โ€” fifteen rooms, written in Fluent itself
tests.ts language tests (bun test ./tests.ts)
tests.browser.ts IDE tests in real Chromium (bun run test:browser)