Sprout among the languages
Sprout is a small language for games and simulations, and a bit of a magpie: it took good ideas from older languages and left the rest. Here it stands beside thirteen of them, from BASIC and Smalltalk to Elm, with the same small programs written side by side.
On this page: one plus two times three · at a glance · four small programs · what Sprout took · better choices
What's unusual
- Values never change. There is no assignment.
withmakes a new record and leaves the old one as it was. - Everything is a cell. A function, a list and a record are all written in square brackets, and they all work the same way.
- One value is sent at a time, left to right. There is no precedence table, so
1 + 2 * 3is 9. Round brackets go first when you want them to. - Games rewind. Since no state is ever changed, a running game's past is just a list of states. Scrub back through it, replay it exactly (random numbers are recorded as they're drawn), or change the code and carry on from there, in the editor or in Greenhouse.
- Frozen copies. Each published game keeps a copy of Sprout as it was on the day the game was finished, in the game's own folder. The language can keep growing, and no finished game breaks.
- The consoles. A game can come in a handheld of its own: SPROUT·8 and SPROUT·16 with the screens and colours of the 8-bit and 16-bit years, SPROUT·256, the future as 1995 drew it, and SPROUT·NOW, smooth and modern, edge to edge on a phone.
Here is most of it in a few lines. The grey lines are the answers, worked out by Sprout itself:
double : [n | n * 2]
point : [x : 3, y : 4]
primes : [2, 3, 5, 7]
primes collect double
-- [4, 6, 10, 14]
point with [x : double 5]
-- [x : 10, y : 4]
point
-- [x : 3, y : 4]
1 + 2 * 3
-- 9
One plus two times three
Every language has to decide what to work out first. Most borrow the rule from school, where times goes before plus. Sprout does what Smalltalk and Rebol do and simply reads from left to right. APL has no rule either, but reads from the right.
| Reads | 1 + 2 * 3 | 2 * 3 + 1 |
|---|---|---|
| Left to rightSprout, Smalltalk, Rebol | 9 | 7 |
| By precedencePython, JavaScript, Lua, Ruby, Haskell, Elm, BASIC, HyperTalk | 7 | 7 |
| Right to leftAPL, which writes × for times | 7 | 8 |
Clojure and Scratch never meet the question. In Clojure you write the nesting yourself, (+ 1 (* 2 3)), and in Scratch you drop one block inside the other. Sprout's answers were run, and so were Python's, JavaScript's, Ruby's and Lua's; the rest follow from each language's rules.
At a glance
Sprout and thirteen others, oldest first after Sprout. Read across for one language, or down a column to see where Sprout sits.
| Language | Do values change? | Order of work | A function | A record | Laziness | Live coding and rewind | Where it runs | Types |
|---|---|---|---|---|---|---|---|---|
| Sprout2026 | Never: with makes a new one | Left to right, one send at a time | [n | n * 2] | [x : 1, y : 2], a cell | A field is worked out when first read, then kept; endless lists | Edit while it runs; every game rewinds and replays | Any browser, phone or desk; Node | Dynamic; an unknown message gives false and a note |
| BASIC1964 | Yes: LET X = X + 1 | Precedence | DEF FND(N) = N * 2 | None in the classic dialects | Eager | Type a line, RUN; edit, RUN again | In the ROM of the home computers | Numbers, and text in names ending in $ |
| APL1966 | Arrays are values; a name can take a new one | Right to left, no precedence | {⍵×2} | Arrays; namespaces in Dyalog | Eager | A live session and workspace; no rewind | Dyalog, GNU APL; TryAPL in a browser | Dynamic arrays of numbers or characters |
| Smalltalk1972 | Yes: objects change in place | Left to right; unary messages first, keywords last | [:n | n * 2] | An object of a class | Eager; a block waits to be sent value | The whole system is live, even the debugger; no rewind | Its own image and VM: Pharo, Squeak | Dynamic; doesNotUnderstand: |
| HyperTalk1987 | Yes: put changes a container | Precedence | function double n … end double | A card with fields | Eager | Always live: edit a button's script, then click it | HyperCard on the classic Mac; LiveCode today | Everything is text |
| Haskell1990 | Never; effects go through IO | Precedence, set per operator | \n -> n * 2 | P { x = 1, y = 2 } | Lazy throughout, each value worked out once | GHCi and :reload; no rewind | Compiled to native code | Static, inferred, with type classes |
| Python1991 | Yes: lists, dicts and objects change in place | Precedence | lambda n: n * 2 | A dict, or a dataclass | Eager; generators are lazy | A REPL; no rewind | Desktops and servers; browsers through Pyodide | Dynamic, with optional hints |
| Lua1993 | Yes: tables change in place | Precedence | function(n) return n * 2 end | A table, {x = 1, y = 2} | Eager; coroutines | Often reloaded inside a running game; no rewind | Anywhere C runs, inside games and apps | Dynamic |
| JavaScript1995 | Yes: const only stops a name being reused | Precedence | n => n * 2 | An object, {x: 1, y: 2} | Eager; generators are lazy | Hot reload in tools; Redux's tools step back in time | Every browser; Node, Deno, Bun | Dynamic, with quiet conversions; TypeScript adds types |
| Ruby1995 | Yes, until you freeze | Precedence | { |n| n * 2 }, a block | A hash, {x: 1, y: 2}, or Data | Eager; .lazy enumerators | irb; classes reopen while running; no rewind | Servers and scripts | Dynamic, duck typed |
| Rebol1997 | Yes: series and objects change in place | Left to right | func [n] [n * 2] | make object! [x: 1 y: 2] | A block is data until you do it | A console; no rewind | A tiny interpreter; Red carries it on | Dynamic, with dates, money, pairs and urls |
| Clojure2007 | Never; atoms hold what does change | Prefix: you write the nesting | (fn [n] (* n 2)) | A map, {:x 1 :y 2} | Lazy sequences | A REPL into the running program | The JVM; browsers through ClojureScript | Dynamic |
| Scratch2007 | Yes: “change score by 1” | Blocks nest, so their shape is the order | A block of your own, from My Blocks | None: variables and lists | Eager | Always live: click a block while it runs | Browsers and the Scratch app | Numbers and text, converted as needed |
| Elm2012 | Never | Precedence | \n -> n * 2 | { x = 1, y = 2 }, its fields fixed by its type | Eager | A debugger that steps back through every message | Browsers, compiled to JavaScript | Static, inferred; no runtime exceptions in practice |
The table scrolls sideways; the names stay put.
Four small programs
Four small jobs, in Sprout and in four languages many people already know. Every one was run. Beside each is the answer Sprout gave, or what the others printed.
Add up the squares of the odd numbers
xs : [3, 8, 5, 2, 7]
xs keep [n | n odd] collect [n | n * n] sum83
xs = [3, 8, 5, 2, 7]
print(sum(n * n for n in xs if n % 2 == 1))83
const xs = [3, 8, 5, 2, 7];
console.log(xs.filter(n => n % 2 === 1)
.map(n => n * n).reduce((a, b) => a + b, 0));83
xs = [3, 8, 5, 2, 7]
puts xs.select(&:odd?).sum { |n| n * n }83
local xs = {3, 8, 5, 2, 7}
local total = 0
for _, n in ipairs(xs) do
if n % 2 == 1 then total = total + n * n end
end
print(total)83
Sprout, Ruby and JavaScript read in the order the work happens: keep the odd ones, square them, add them up. Python's generator starts with the square and ends with the test, and Lua writes the loop out with a running total. On a long list of numbers Sprout runs its whole chain as one loop, with no lists made in between.
Count each word in a sentence
"the cat sat on the mat" words tally[the : 2, cat : 1, sat : 1, on : 1, mat : 1]
from collections import Counter
print(Counter("the cat sat on the mat".split()))Counter({'the': 2, 'cat': 1, 'sat': 1, 'on': 1, 'mat': 1})const counts = {};
for (const w of "the cat sat on the mat".split(" "))
counts[w] = (counts[w] ?? 0) + 1;
console.log(counts);{ the: 2, cat: 1, sat: 1, on: 1, mat: 1 }p "the cat sat on the mat".split.tally{"the"=>2, "cat"=>1, "sat"=>1, "on"=>1, "mat"=>1}local counts = {}
for w in ("the cat sat on the mat"):gmatch("%S+") do
counts[w] = (counts[w] or 0) + 1
end
print(counts.the, counts.cat, counts.mat)2 1 1
Ruby calls it tally, and so does Sprout, which took the word from Ruby; Clojure's name for it, frequencies, works too. Python keeps a Counter in its library. JavaScript and Lua count by hand, changing a table as they go, and a Lua table has no order and no way to print itself, so Lua prints three of the counts.
Add a field to a record
pip : [name : "Pip", leaves : 2]
tall : pip with [height : 12]
[pip, tall][[name : Pip, leaves : 2], [name : Pip, leaves : 2, height : 12]]
pip = {"name": "Pip", "leaves": 2}
tall = {**pip, "height": 12}
print(pip)
print(tall){'name': 'Pip', 'leaves': 2}
{'name': 'Pip', 'leaves': 2, 'height': 12}const pip = { name: "Pip", leaves: 2 };
const tall = { ...pip, height: 12 };
console.log(pip);
console.log(tall);{ name: 'Pip', leaves: 2 }
{ name: 'Pip', leaves: 2, height: 12 }pip = { name: "Pip", leaves: 2 }
tall = pip.merge(height: 12)
p pip
p tall{:name=>"Pip", :leaves=>2}
{:name=>"Pip", :leaves=>2, :height=>12}local pip = {name = "Pip", leaves = 2}
local tall = {height = 12}
for k, v in pairs(pip) do tall[k] = v end
print(pip.height, tall.height, tall.name)nil 12 Pip
All five can make a new record and leave the old one alone. The difference is what else they allow. In Python, JavaScript, Ruby and Lua, anyone holding pip can still change it in place, and everyone else holding it sees the change. In Sprout nobody can, ever, so a value you've seen stays the value you saw. Elm and Haskell make the same promise, though an Elm record keeps the fields its type gave it, so adding one means a new type.
A counter that remembers
A tap counter, kept the way a game keeps its state: an update takes the state and an event and gives back the next state. Each version runs four events and keeps every state along the way.
start : [taps : 0]
update : [game event |
event = "tap" [game with [taps : game taps + 1]] else [game]
]
["tap", "tick", "tap", "tap"] scan [start, update][[taps : 0], [taps : 1], [taps : 1], [taps : 2], [taps : 3]]
from itertools import accumulate
def update(game, event):
if event == "tap":
return {**game, "taps": game["taps"] + 1}
return game
events = ["tap", "tick", "tap", "tap"]
print(list(accumulate(events, update, initial={"taps": 0})))[{'taps': 0}, {'taps': 1}, {'taps': 1}, {'taps': 2}, {'taps': 3}]const update = (game, event) =>
event === "tap" ? { ...game, taps: game.taps + 1 } : game;
const history = [{ taps: 0 }];
for (const event of ["tap", "tick", "tap", "tap"])
history.push(update(history.at(-1), event));
console.log(history);[ { taps: 0 }, { taps: 1 }, { taps: 1 }, { taps: 2 }, { taps: 3 } ]def update(game, event)
event == "tap" ? game.merge(taps: game[:taps] + 1) : game
end
history = [{ taps: 0 }]
["tap", "tick", "tap", "tap"].each do |event|
history << update(history.last, event)
end
p history[{:taps=>0}, {:taps=>1}, {:taps=>1}, {:taps=>2}, {:taps=>3}]local function update(game, event)
if event == "tap" then return {taps = game.taps + 1} end
return game
end
local history = {{taps = 0}}
for _, event in ipairs({"tap", "tick", "tap", "tap"}) do
history[#history + 1] = update(history[#history], event)
end
for _, game in ipairs(history) do io.write(game.taps, " ") end
print()0 1 1 2 3
Every one of these keeps its history, because each update here gives back a new state. In Python, JavaScript (it's how Redux works), Ruby and Lua that's a habit, and nothing holds you to it: had Python's update added to game["taps"] in place, its list would read 3, 3, 3, 3, 3, every entry the same dict. In Sprout it's the only way an update can be written, so the game loop keeps the list for you, and that list is the rewind. In a real game the events are the ticks, taps and keys, and the random numbers drawn along the way are recorded too, so a replay comes out the same, frame for frame. Elm's update has this shape and makes the same promise.
What Sprout took, and what it left
Seven of these languages lent Sprout something on purpose, and the spec records each loan as a numbered decision. Six more sit close by: they reached some of the same ideas first, or chose the other way, and they help show where Sprout stands. The lines of Sprout below were run; lines of the other languages are written from their documentation.
Borrowed from
Smalltalk 1972
Took the one move everything is made of: send a message to a value, then the next message to the answer, left to right, operators included. Blocks with a bar after their inputs: Smalltalk's [:n | n * 2] is Sprout's [n | n * 2]. A value that doesn't understand a message says so and the program carries on, and now any value can be asked what it understands:
3 responds-to "pow"
-- true
"hi" responds-to "pow"
-- false
Left classes, since a value gets its methods through with; unary messages going before operators, so Sprout's a x + r x is ((a x) + r) x; keyword messages like at: 1 put: 2 and cascades, which would be new grammar and wait as proposals; objects that change.
HyperTalk 1987
Took the chunk words, so text reads the way HyperCard read it, and stack, for an app made of cards that can go next, go by name, find words, put a value into a field and add a card.
"the quick brown fox" word 2
-- quick
"red, green, blue" item 2
-- green
Left the English sentences, as in put word 2 of field "notes" into field "title", which would change Sprout's grammar and wait as a proposal; and values that are all text.
Lua 1993
Took one structure for lists and records, counted from 1, as a Lua table is; .. to join; the string words; coroutines, which became scripts that stay values; and from metatables, the idea that a record can carry its own +.
"lives: " .. 3
-- lives: 3
["map", "lamp", "rope"] @ 1
-- map
Left nil, since Sprout's one empty value is false; tables that change under you; the C interface for living inside other programs. Sprout and Lua, side by side
JavaScript 1995
Took a home. Sprout compiles to JavaScript and runs wherever it runs, on a phone or a desk, with WebAssembly and WebGPU for the heaviest loops, and popular JavaScript libraries (chroma, simplex noise, math.js, date-fns, Fuse, compromise, Tone, Turf and ZzFX) are Sprout modules.
Left this, null and undefined, precedence, objects that change in place, and quiet conversions: JavaScript's "5" * 2 is 10. Sprout's text doesn't know *, so it says so, and you say what you mean:
"5" responds-to "*"
-- false
"5" number * 2
-- 10Ruby 1995
Took some of Ruby's best-loved words. And from _why, who wrote about Ruby with cartoon foxes, a storybook, A Slightly Soggy Guide to Sprout, and, after his little language Potion, lick, which reads data written as an indented outline.
5 then [n | n * 2]
-- 10
"az" succ
-- ba
1907 digits
-- [1, 9, 0, 7]
Ruby's 1907.digits comes ones first, [7, 0, 9, 1]; Sprout's come in reading order.
Left names ending in ? and ! and method_missing, which wait as proposals; classes; objects that change.
Rebol 1997
Took values written as they are, dates, times, money, pairs, urls and colours, each with its own math; parse, with rules that are ordinary values; reading left to right; code as data.
2026-12-25 - 2026-11-23
-- 32
2026-11-23 weekday
-- Monday
15% * 80
-- 12
Left words looked up late, since a Sprout name is bound before it's used; series that change in place; blocks that need no quote. Sprout and Rebol, side by side
Clojure 2007
Took values that never change, as the normal case; the sequence words, frequencies, group-by, partition and the rest; endless lists, worked out only as far as they're read; unpacking a value into names; update-in.
cycle ["red", "amber", "green"] take 5
-- [red, amber, green, red, amber]
Left Lisp's brackets with the function first, and macros; the JVM; atoms and threads. Sprout and Clojure, side by side
Close by
BASIC 1964
Shares the feeling of a machine that switches on ready to play. BASIC was the language a home computer greeted you with. Sprout's games come in handhelds of their own, and any of them opens in the editor to be looked at and changed.
Left line numbers, GOTO, and variables that any line can change.
APL 1966
Shares no precedence table, one rule for order, and working on a whole list at once:
range 5 collect [n | n * n]
-- [1, 4, 9, 16, 25]
2 * 3 + 1
-- 7
APL writes the first as (⍳5)*2, and its 2×3+1 is 8, since it reads from the right.
Left the symbols, and reading right to left.
Haskell 1990
Shares values that never change, and laziness of the same kind: a field of a Sprout cell is worked out the first time it's read and then kept, which is how Haskell works out everything. Endless lists too; Haskell says take 6 (iterate (*2) 1):
iterate [1, [n | n * 2]] take 6
-- [1, 2, 4, 8, 16, 32]
Left types and type classes, and monads for effects: Sprout queues a game's sounds and other effects, and the host carries them out after update.
Python 1991
Shares an indent that means something: a new line and an indent make a cell.
size :
w : 360
h : 480
size h
-- 480
And text with values in it: Python's f"{name}" is Sprout's "[name]".
Left statements and return, since the last value is the answer; precedence; lists and dicts that change in place. Sprout and Python, side by side
Scratch 2007
Shares games first, in the browser, for people starting out, and a program you can change while it runs.
Left the blocks you drag. Sprout is typed, but its editor is made for touch: a key bar, live values beside each line, numbers you drag to change, and history to scrub back through.
Elm 2012
Shares the shape of a program. Elm's init, update and view are Sprout's start, update and draw, and in both, update gives back a new state instead of changing the old one. That's what lets Elm's debugger step back through every message, and every Sprout game rewind.
Left static types, and a compiler that checks every case before anything runs.
When another language is the better choice
Sprout is good at one thing: small games and simulations that run in a browser and can be changed while they run. For most other work, something on this page will serve you better.
- Python for data, science, machine learning and scripts for your own computer. Its libraries cover nearly everything.
- JavaScript, or TypeScript, for web apps built by a team, with npm's packages and every browser's tools.
- Lua to script a game engine or a program written in C, or PICO-8, Lua's fantasy console, if you'd like a big, friendly community making tiny games.
- Ruby for a web service with Rails behind it.
- Smalltalk, as Pharo, for a whole live world to explore, debugger and all.
- Elm when the compiler should rule out crashes in a browser app before anyone runs it, and Haskell when types should carry the design of a large program.
- Clojure for big data systems on the JVM, with threads and Java's libraries.
- Scratch for a child's first programs: there's no syntax to get wrong.
- APL for array math in a single line.
And where Sprout is weaker, plainly:
- It's young and small. It lives on one site, with few users, no package manager, a library of its own modules and nine wrapped JavaScript libraries.
- It has no static types. A misspelled word or a missing field gives false and a note, with a suggestion, rather than stopping, so a mistake can travel a while before you see it.
- A branch that gives false runs its
elseas well;condis the way round it. - A name must be bound before it's used, so two cells can't call each other.
- Away from loops over numbers, where it's quick, it's a little slower than plain JavaScript:
fib 25takes about 3 ms against 1.3. - It runs in a browser or in Node, and nowhere else.
One on one
For four of these languages there's a longer page, with a dozen or so programs side by side, each pair run.
- Sprout and PythonFunctions, choices, lists, records, recursion and a million random trials.
- Sprout and RebolLiterals, parse, grammars, dialects and code as data.
- Sprout and ClojurePipelines, counting, grouping, endless lists and unpacking.
- Sprout and LuaTables, strings, patterns, coroutines, operators and money.