Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Polyglot Pipeline

The same data, handled by the language best suited to each step, with Crush variables as the glue. This replaces an earlier “Async LLM Dashboard” page whose dom.*, seahorse and async/await calls do not run in the current toolchain.

Run it with crush run --polyglot poly.crush (needs python3, node and bash on PATH; crush doctor checks).

Verified against crush-ast v0.13.0 (dc0d0278, 2026-12-03).

// Three languages, one program. Values flow through Crush variables.
let numbers = [3, 1, 4, 1, 5, 9, 2, 6]

@python -> mean {
import statistics
mean = statistics.mean(numbers)
}

@javascript -> spread {
const spread = Math.max(...numbers) - Math.min(...numbers)
}

@python -> line {
line = f"mean={mean} spread={spread}"
}
print(line)

@bash {
echo "bash: $(echo done)"
}
print("")
mean=3.875 spread=8
bash: done

What this shows:

  • @python -> mean: the block reads the Crush variable numbers (inputs are automatic) and declares mean as its output, which becomes a Crush variable
  • @javascript -> spread: the same protocol; spread comes back as a number
  • the second @python block reads both earlier outputs, because they are Crush variables now
  • @bash: only its printed output comes back. It could read a Crush variable by naming it ($name), but it has no way to hand a value back, which is why the formatting is done in Python
  • block output is trimmed and has no trailing newline, which is why print("") is used to finish the line
  • all three run as ordinary subprocesses with your user’s authority — see Polyglot Programming