Sprout compared
Sprout next to four languages, each at what it is known for: Python for being first, Rebol for literals and parsing, Clojure for data and sequences, Lua for tables, strings and coroutines. Every Sprout program here was run, and so was every Python, Clojure and Lua program, with the output each one actually printed. Rebol isn't installed here, so its side is written from its documentation and marked. Back to Sprout 3
| Sprout | Python | Rebol | Clojure | Lua | |
|---|---|---|---|---|---|
| Math order | left to right, no precedence | precedence rules | left to right | prefix: (+ 1 2) | precedence rules |
| Functions | cells: [n | n * 2] | def, lambda | func | fn, defn | function |
| Control | library cells, not syntax | keywords | functions | special forms and macros | keywords |
| Changing data | never in place | in place | in place | never in place | in place |
| Literals | dates, times, money, pairs, urls, emails, colours | numbers and text | dates, money, pairs, urls and more | keywords, sets, regexes | numbers and text |
| Parsing | parse with rules as values | re | parse | regexes | patterns |
| Code as data | quote, eval, code | ast module | blocks | lists and macros | strings and load |
| Coroutines | script, a value you can rewind | generators | none | none built in | coroutines |
| Speed on number loops | fused loops, SIMD and WebGPU kernels | interpreted; NumPy for arrays | interpreted | the JVM, after start-up | a fast interpreter; LuaJIT |
| Where it still leads | games and simulations in a browser, live editing, rewind | libraries for everything | blocks need no quote; late binding | macros, the JVM, threads | a tiny embeddable C core |
Speed
The same work on one machine, best of several runs. Sprout ran in Node; Clojure's time is after the JVM has warmed up, which takes about a second and a half. A dot means it wasn't measured.
| work | Sprout | Python 3.13 | Clojure 1.12 | Lua 5.4 |
|---|---|---|---|---|
| A million Monte Carlo trials (pi) | 19 ms | 200 ms | ยท | 72 ms |
| Counting a million numbers | 4.3 ms | 36 ms | 14 ms | 13 ms |
Sprout and Python
Python is the language most people learn first. Every pair was run in Sprout 3 and Python 3.13, and the output under each one is what it actually printed.
Printing
In Sprout the message comes after the value: "hello, world" print sends print to the text. Every line reads the same way, from the thing to what happens to it.
"hello, world" printhello, world
print("hello, world")hello, world
Names for values
A colon gives a value a name. Names can have hyphens in them, like star-count, because minus always has spaces round it.
price : 12
count : 3
price * count print36
price = 12
count = 3
print(price * count)36
Left to right, always
Sprout has no precedence table. Math runs strictly left to right, so 2 + 3 * 4 is 20. Use brackets when you want something done first. There is nothing to remember.
2 + 3 * 4 print
2 + (3 * 4) print20 14
print((2 + 3) * 4)
print(2 + 3 * 4)20 14
Functions are cells
A function is a cell: inputs, a bar, then the body. The last value in the body is the answer, so there is no return. To call it, write the value after its name.
double : [n | n * 2]
double 21 print42
def double(n):
return n * 2
print(double(21))42
Several inputs, and defaults
Every call takes one value. Several inputs go in as a list, in order, or as a record, by name. A default comes after a colon, the same way a name gets a value.
area : [w h : 1 | w * h]
area [3, 4] print
area [5] print
area [h : 2, w : 6] print12 5 12
def area(w, h=1):
return w * h
print(area(3, 4))
print(area(5))
print(area(h=2, w=6))12 5 12
Choosing
There is no if keyword. A true or false value takes a cell to run when true, and else (an ordinary library cell) takes the other one. The whole thing is a value, like Python's conditional expression.
size : [n | n > 100 ["big"] else ["small"]]
size 250 print
size 7 printbig small
def size(n):
return "big" if n > 100 else "small"
print(size(250))
print(size(7))big small
Lists
collect, keep and fold are methods on the list, so a chain of them reads left to right. Python spreads the same work over comprehensions and built-in functions.
xs : [3, 1, 4, 1, 5, 9]
xs collect [n | n * 2] print
xs keep [n | n > 2] print
xs fold [0, [total n | total + n]] print
xs sort print[6, 2, 8, 2, 10, 18] [3, 4, 5, 9] 23 [1, 1, 3, 4, 5, 9]
xs = [3, 1, 4, 1, 5, 9]
print([n * 2 for n in xs])
print([n for n in xs if n > 2])
print(sum(xs))
print(sorted(xs))[6, 2, 8, 2, 10, 18] [3, 4, 5, 9] 23 [1, 1, 3, 4, 5, 9]
Records, never changed in place
A record is a list of named fields. with makes a new record with some fields changed; the old one is never touched. Nothing in Sprout changes in place, which is why a game's state can be saved, rewound or compared at any time.
point : [x : 1, y : 2]
point x print
moved : point with [x : 5]
moved print
point print1 [x : 5, y : 2] [x : 1, y : 2]
point = {"x": 1, "y": 2}
print(point["x"])
moved = {**point, "x": 5}
print(moved)
print(point)1
{'x': 5, 'y': 2}
{'x': 1, 'y': 2}Text with values in it
Square brackets inside text hold a value, the same as Python's f-strings with braces. Any expression works inside them.
name : "Ada"
"hello, [name]! you have [3 * 4] messages" printhello, Ada! you have 12 messages
name = "Ada"
print(f"hello, {name}! you have {3 * 4} messages")hello, Ada! you have 12 messages
A field that may not be there
Asking for a field that isn't there is a quiet miss, not a crash, and else catches it. Python needs .get or a try for the same thing.
user : [name : "Ada"]
user nickname else "none" printnone
user = {"name": "Ada"}
print(user.get("nickname", "none"))none
Matching
match is a library cell, not syntax: a value and a flat list of pattern and answer pairs. any matches anything.
answer : [key | match [key, ["tap", "tapped", "drag", "dragged", any, "other"]]]
answer "tap" print
answer "swipe" printtapped other
def answer(key):
match key:
case "tap": return "tapped"
case "drag": return "dragged"
case _: return "other"
print(answer("tap"))
print(answer("swipe"))tapped other
Chains of steps
Because methods go after the value, a pipeline reads in the order it runs. Python's comprehension puts the result first and the source in the middle.
people : [[name : "Ada", age : 36], [name : "Alan", age : 41], [name : "Grace", age : 85]]
people keep [p | p age > 40] collect [p | p name] print[Alan, Grace]
people = [{"name": "Ada", "age": 36}, {"name": "Alan", "age": 41}, {"name": "Grace", "age": 85}]
print([p["name"] for p in people if p["age"] > 40])['Alan', 'Grace']
FizzBuzz
cond takes pairs of test and answer and gives the first answer whose test is true. Lists in Sprout count from 1, so range 15 is 1 to 15.
range 15 collect [n | cond [n % 15 = 0, "FizzBuzz", n % 3 = 0, "Fizz", n % 5 = 0, "Buzz", any, n]] print[1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz]
print(["FizzBuzz" if n % 15 == 0 else "Fizz" if n % 3 == 0 else "Buzz" if n % 5 == 0 else n
for n in range(1, 16)])[1, 2, 'Fizz', 4, 'Buzz', 'Fizz', 7, 8, 'Fizz', 'Buzz', 11, 'Fizz', 13, 14, 'FizzBuzz']
Recursion
A cell can call itself by name. The brackets round n - 1 matter: without them, left to right would read fib n - 1 as (fib n) - 1.
fib : [n | n < 2 [n] else [fib (n - 1) + (fib (n - 2))]]
fib 20 print6765
def fib(n):
return n if n < 2 else fib(n - 1) + fib(n - 2)
print(fib(20))6765
A million random trials
This is where the two part ways. noise [n, 1] is a seeded hash, not a random number generator, so run n always draws the same numbers and the answer is the same every time. Because hit is one pure cell, spork compiles it ahead into a kernel of number math and runs it on WebAssembly SIMD or the GPU. In this test, Sprout took 19 ms in Node against 200 ms for the plain CPython loop. NumPy would close most of that gap, at the cost of rewriting the loop as array operations.
-- estimate pi: the share of random points in the square that land inside the circle
hit : [n | x : noise [n, 1], y : noise [n, 2], x * x + (y * y) < 1 [1] else [0]]
range 1000000 spork hit fold [0, [total h | total + h]] * 4 / 1000000 print3.141792
import random
hits = sum(1 for _ in range(1_000_000)
if random.random() ** 2 + random.random() ** 2 < 1)
print(hits * 4 / 1_000_000)3.137976
Sprout and Rebol
Rebol showed that a language could be tiny, read left to right, write dates and money as they are, and parse anything with a dialect. Sprout takes all of that. Every Sprout side here was run, and its output is real. Rebol isn't installed on this machine, so the Rebol side is written from Rebol 3's documentation and wasn't run.
Values written as they are
Rebol's best idea: a date, an amount of money or a size is written as it is, and knows its own math. Sprout writes dates the ISO way, 2026-11-20, and keeps money in whole cents.
2026-11-20 + 30 print
$19.99 * 3 print
640x480 / 2 print
9:30 + 0:45 print2026-12-20 $59.97 320x240 10:15
print 20-Nov-2026 + 30
print $19.99 * 3
print 640x480 / 2
print 9:30 + 0:45Left to right, like Rebol
Rebol and Sprout agree: math runs strictly left to right, so this is 20 in both.
2 + 3 * 4 print20
print 2 + 3 * 4Functions
Rebol's func takes a block of inputs and a block of code. A Sprout cell is both in one pair of brackets.
twice : [n | n * 2]
twice 21 print42
twice: func [n] [n * 2]
print twice 21Parsing text
Rebol copies each piece into a variable. Sprout keeps them with as and gives back a record, so nothing outside the rule changes.
"2026-11-20" parse [repeat [4, digit] as "year", "-", repeat [2, digit] as "month", "-", repeat [2, digit] as "day"] print[year : 2026, month : 11, day : 20]
digit: charset "0123456789"
parse "2026-11-20" [copy year 4 digit "-" copy month 2 digit "-" copy day 2 digit]
print [year month day]Finding every match
Rebol collects matches with an action in parens. Sprout has find-all.
"call 555-1234 or 555-9876 today" find-all [repeat [3, digit], "-", repeat [4, digit]] print[555-1234, 555-9876]
digit: charset "0123456789"
found: copy []
parse "call 555-1234 or 555-9876 today" [
some [copy number [3 digit "-" 4 digit] (append found number) | skip]
]
probe foundA grammar
Rebol words are looked up when the rule runs, so rules can refer to each other in any order. Sprout names are bound before use (decision 25), so the grammar is one cell that names itself, with its pieces as fields.
expr : [
factor : one-of [some digit, ["(", expr, ")"]]
term : [factor, maybe-some [one-of "*/", factor]]
term, maybe-some [one-of "+-", term]
]
["2*(3+4)", "2*(3+4", "1+2*3-4/5"] collect [t | t parse expr] print[true, false, true]
digit: charset "0123456789"
expr: [term any [["+" | "-"] term]]
term: [factor any [["*" | "/"] factor]]
factor: [some digit | "(" expr ")"]
probe collect [foreach t ["2*(3+4)" "2*(3+4" "1+2*3-4/5"] [keep parse t expr]]A dialect
Rebol's is shorter: a block is already flat data. Sprout's quoted code keeps its phrases, so each command is checked as a whole with into.
turtle : some one-of [into ['move, a-number], into ['turn, a-number]]
quote [move 10, turn 90, move 5] parse turtle printtrue
turtle: [some ['move integer! | 'turn integer!]]
print parse [move 10 turn 90 move 5] turtleRunning a dialect
Rebol runs code in parens as the rule matches, and changes variables as it goes. Sprout folds over the program and gives back the new state, so nothing changes underneath.
walk : [state [command, amount] |
match [command, ['move, state with [x : state x + amount], 'turn, state with [heading : state heading + amount], any, state]]
]
quote [move 10, turn 90, move 5] fold [[x : 0, heading : 0], walk] print[x : 15, heading : 90]
x: 0 heading: 0
parse [move 10 turn 90 move 5] [
some ['move set n integer! (x: x + n) | 'turn set n integer! (heading: heading + n)]
]
print [x heading]Code is data
Both treat code as data. Rebol blocks are data until you do them; Sprout needs quote, because its brackets are cells. Both can get a function's body back.
program : quote [1 + 2, 3 * 4]
program print
eval program print
twice : [n | n * 2]
twice code print[1 + 2, 3 * 4] 12 [n | n * 2]
program: [1 + 2 3 * 4]
probe program
print do program
twice: func [n] [n * 2]
probe body-of :twiceRecords that don't change underneath you
Rebol makes a new object from an old one too, but any object can also be changed in place, for everyone who holds it. A Sprout record never changes, so a game can rewind.
point : [x : 1, y : 2]
moved : point with [x : 5]
moved print
point print[x : 5, y : 2] [x : 1, y : 2]
point: make object! [x: 1 y: 2]
moved: make point [x: 5]
probe moved
point/x: 5 ; and an object can also be changed in place, for everyone holding it
probe pointCoroutines
Rebol has no coroutines. Sprout's script yields values and stays a value (decision 104).
squares : script [| go : [n | yield (n * n), go (n + 1)], go 1]
squares take 5 print[1, 4, 9, 16, 25]
; Rebol has no coroutines: a generator keeps its place in a variable
n: 0
next-square: does [n: n + 1 n * n]
probe collect [loop 5 [keep next-square]]Unpacking
Rebol reads parts by path, size/x. Sprout can also unpack a pair or a date into names at once (decision 101).
[w, h] : 640x480
w * h print
[y, m, d] : 2026-11-20
"[d]/[m]/[y]" print307200 20/11/2026
size: 640x480
print size/x * size/y
day: 20-Nov-2026
print rejoin [day/day "/" day/month "/" day/year]Sprout and Clojure
Clojure made immutable data and a rich sequence library feel normal. Here is what it is known for, next to the same work in Sprout. Every pair was run in Sprout 3 and in Clojure 1.12, and the output under each one is what it actually printed. The two print collections differently; the values are the same.
A pipeline of steps
Clojure needs the ->> macro to write steps in the order they run. In Sprout every method already reads left to right, so a pipeline is just a line.
1 to 10 keep [n | n even] collect [n | n * n] sum print220
(println (->> (range 1 11) (filter even?) (map #(* % %)) (reduce +)))220
Counting
The same words, the same counts. Sprout prints a record, Clojure a map.
"mississippi" chars frequencies print[m : 1, i : 4, s : 4, p : 2]
(println (frequencies "mississippi")){m 1, i 4, s 4, p 2}Grouping
group-by in both. Sprout's keys are the text of each value, since a record's field names are words.
people : [[name : "Ada", age : 36], [name : "Alan", age : 41], [name : "Grace", age : 85]]
people group-by [p | p age > 40] print[false : [[name : Ada, age : 36]], true : [[name : Alan, age : 41], [name : Grace, age : 85]]]
(def people [{:name "Ada" :age 36} {:name "Alan" :age 41} {:name "Grace" :age 85}])
(println (group-by #(> (:age %) 40) people)){false [{:name Ada, :age 36}], true [{:name Alan, :age 41} {:name Grace, :age 85}]}Changing something deep inside
Both give a new game and leave the old one as it was. Clojure's keywords make the path shorter; Sprout's path is plain text.
game : [player : [name : "Ada", score : 10]]
game update-in [["player", "score"], [s | s + 5]] print
game print[player : [name : Ada, score : 15]] [player : [name : Ada, score : 10]]
(def game {:player {:name "Ada" :score 10}})
(println (update-in game [:player :score] + 5))
(println game){:player {:name Ada, :score 15}}
{:player {:name Ada, :score 10}}Unpacking
Clojure's destructuring, in Sprout's square brackets (decision 101). One pattern unpacks a record by name or a list by position, and ..rest is Clojure's &.
greet : [[name, age] | "[name] is [age]"]
greet [name : "Ada", age : 36] print
[first, ..rest] : [1, 2, 3, 4]
rest printAda is 36 [2, 3, 4]
(defn greet [{:keys [name age]}] (str name " is " age))
(println (greet {:name "Ada" :age 36}))
(let [[first & rest] [1 2 3 4]] (println rest))Ada is 36 (2 3 4)
Endless lists
Endless lists in both, worked out only as far as they are read. The Fibonacci line unpacks each pair as it goes.
iterate [1, [n | n + 1]] keep [n | n % 7 = 0] take 5 print
iterate [[0, 1], [[a, b] | [b, a + b]]] collect [[a, b] | a] take 10 print[7, 14, 21, 28, 35] [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
(println (take 5 (filter #(zero? (mod % 7)) (iterate inc 1))))
(println (take 10 (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1]))))(7 14 21 28 35) (0 1 1 2 3 5 8 13 21 34)
Slicing a list up
Clojure's sequence words have Sprout names: partition, scan for reductions, zip for map vector.
1 to 10 partition 3 print
[3, 1, 4, 1, 5] scan [0, [t n | t + n]] print
[1, 2, 3] zip ["a", "b", "c"] print[[1, 2, 3], [4, 5, 6], [7, 8, 9]] [0, 3, 4, 8, 9, 14] [[1, a], [2, b], [3, c]]
(println (partition 3 (range 1 11)))
(println (reductions + 0 [3 1 4 1 5]))
(println (map vector [1 2 3] ["a" "b" "c"]))((1 2 3) (4 5 6) (7 8 9)) (0 3 4 8 9 14) ([1 a] [2 b] [3 c])
Code is data
Both can hold code as data and run it. A Sprout cell also keeps its own code, so twice code gives it back; a compiled Clojure function is an object, and its source lives only in the file.
program : quote [1 + 2, 3 * 4]
program print
eval program print
twice : [n | n * 2]
twice code print[1 + 2, 3 * 4] 12 [n | n * 2]
(def program '(do (+ 1 2) (* 3 4)))
(println program)
(println (eval program))
(defn twice [n] (* n 2))
;; a function keeps no code of its own; only the REPL can find its source file
(println twice)(do (+ 1 2) (* 3 4)) 12 #object[user$twice 0x22ee2d0 user$twice@22ee2d0]
A little language
The same little turtle language, as quoted data walked by a fold. Sprout's 'move and Clojure's 'move are both symbols you can compare.
turtle : [state [command, amount] |
match [command, ['move, state with [x : state x + amount], 'turn, state with [heading : state heading + amount], any, state]]
]
quote [move 10, turn 90, move 5] fold [[x : 0, heading : 0], turtle] print[x : 15, heading : 90]
(defn turtle [state [command amount]]
(case command
move (update state :x + amount)
turn (update state :heading + amount)
state))
(println (reduce turtle {:x 0 :heading 0} '[[move 10] [turn 90] [move 5]])){:x 15, :heading 90}Dates
Clojure borrows Java's dates. Sprout writes a date as it is and does its math directly (decision 100).
2026-11-20 + 30 print
2026-11-20 weekday print2026-12-20 Friday
(def day (java.time.LocalDate/parse "2026-11-20"))
(println (str (.plusDays day 30)))
(println (str (.getDayOfWeek day)))2026-12-20 FRIDAY
Counting a million
Counting the multiples of three below a million. Sprout took 4.3 ms on this machine. Clojure took 14 ms once the JVM had warmed up, after about a second and a half to start. A transducer or a loop with primitive math would make Clojure faster.
range 1000000 keep [n | n % 3 = 0] length print333333
(defn run [] (count (filter #(zero? (mod % 3)) (range 1 1000001))))
(println (run))333333
Sprout and Lua
Lua is small, fast and everywhere games are scripted. Here is what it is known for, next to the same work in Sprout. Every pair was run in Sprout 3 and in Lua 5.4, and the output under each one is what it actually printed. Where they differ, the difference is the point.
One structure for records and lists
Both languages have one structure for everything. A Sprout cell holds named fields and numbered parts, as a Lua table does, and lists count from 1 in both.
hero : [name : "Ada", items : ["map", "lamp", "rope"]]
hero name print
hero items @ 2 print
hero items length printAda lamp 3
local hero = {name = "Ada", items = {"map", "lamp", "rope"}}
print(hero.name)
print(hero.items[2])
print(#hero.items)Ada lamp 3
The string library
Lua's string library is short and sharp. Sprout's words are named for what they do, so trimming and splitting don't need a pattern. Both count positions from 1, and negative ones from the end.
line : " Sprout, Lua, Rebol "
line trim print
line trim split ", " join " | " print
"ab" repeat 3 print
"hello" slice [2, -2] print
"hello" upper printSprout, Lua, Rebol Sprout | Lua | Rebol ababab ell HELLO
local line = " Sprout, Lua, Rebol "
local trimmed = line:match("^%s*(.-)%s*$")
print(trimmed)
local parts = {}
for part in trimmed:gmatch("[^,]+") do parts[#parts + 1] = part:match("^%s*(.-)%s*$") end
print(table.concat(parts, " | "))
print(("ab"):rep(3))
print(("hello"):sub(2, -2))
print(("hello"):upper())Sprout, Lua, Rebol Sprout | Lua | Rebol ababab ell HELLO
Finding things in text
Lua patterns are a tiny language inside strings: %d for a digit, %- for a dash. Sprout's rules are ordinary values (decision 103), so they can be named, put in lists and built by other code.
text : "call 555-1234 or 555-9876 today"
text find-all [repeat [3, digit], "-", repeat [4, digit]] join ", " print555-1234, 555-9876
local text = "call 555-1234 or 555-9876 today"
local found = {}
for number in text:gmatch("%d%d%d%-%d%d%d%d") do found[#found + 1] = number end
print(table.concat(found, ", "))555-1234, 555-9876
Replacing with a function
Both replace each match with what a function makes of it. Lua's gsub also gives back a count, which is why its call needs the extra brackets.
"3 apples and 12 pears" replace-all [some digit, [n | n number * 2]] print6 apples and 24 pears
print((("3 apples and 12 pears"):gsub("%d+", function(n) return tonumber(n) * 2 end)))6 apples and 24 pears
A grammar, not just a pattern
Lua patterns can't say "this or that", and can't nest. So nested brackets mean writing a parser by hand. A Sprout rule can hold itself, so the grammar is four lines and reads like a grammar.
expr : [
factor : one-of [some digit, ["(", expr, ")"]]
term : [factor, maybe-some [one-of "*/", factor]]
term, maybe-some [one-of "+-", term]
]
["2*(3+4)", "2*(3+4", "1+2*3-4/5"] collect [t | t parse expr] print[true, false, true]
-- Lua patterns have no alternation and no recursion, so a grammar is a hand-written parser
local function parse(s)
local pos = 1
local expr
local function factor()
if s:sub(pos, pos) == "(" then
pos = pos + 1
if not expr() or s:sub(pos, pos) ~= ")" then return false end
pos = pos + 1
return true
end
local from, to = s:find("^%d+", pos)
if not from then return false end
pos = to + 1
return true
end
local function term()
if not factor() then return false end
while s:sub(pos, pos):match("[*/]") do pos = pos + 1; if not factor() then return false end end
return true
end
expr = function()
if not term() then return false end
while s:sub(pos, pos):match("[+-]") do pos = pos + 1; if not term() then return false end end
return true
end
return expr() and pos == #s + 1
end
local results = {}
for _, t in ipairs({"2*(3+4)", "2*(3+4", "1+2*3-4/5"}) do results[#results + 1] = tostring(parse(t)) end
print("[" .. table.concat(results, ", ") .. "]")[true, false, true]
Coroutines
A generator in both. Sprout's script yields the same way a Lua coroutine does (decision 104).
squares : script [| go : [n | yield (n * n), go (n + 1)], go 1]
squares take 5 join ", " print1, 4, 9, 16, 25
local squares = coroutine.wrap(function()
local n = 1
while true do coroutine.yield(n * n); n = n + 1 end
end)
local out = {}
for i = 1, 5 do out[i] = squares() end
print(table.concat(out, ", "))1, 4, 9, 16, 25
A coroutine you can go back to
This is where they part. A Lua coroutine is one live object: resuming it moves it on for everyone. A Sprout script is a value: resuming gives a new one and leaves the old one as it was. That is why a game can keep a script in its state and still rewind time.
counter : script [| yield 1, yield 2, yield 3]
first : counter next
second : first next
second value print
-- first hasn't changed, so it can be resumed again
first next value print2 2
local counter = coroutine.create(function()
coroutine.yield(1); coroutine.yield(2); coroutine.yield(3)
end)
coroutine.resume(counter)
local _, second = coroutine.resume(counter)
print(second)
-- there is only one counter, and it has moved on
local _, again = coroutine.resume(counter)
print(again)2 3
Your own operators
A Lua metatable gives a table its own +. In Sprout a record has a field named +, and left is the record it was sent to.
vector : [
+ : [right | left with [x : left x + (right x), y : left y + (right y)]]
]
sum : (vector with [x : 1, y : 2]) + (vector with [x : 3, y : 4])
"[sum x], [sum y]" print4, 6
local Vector = {}
Vector.__index = Vector
function Vector.new(x, y) return setmetatable({x = x, y = y}, Vector) end
Vector.__add = function(a, b) return Vector.new(a.x + b.x, a.y + b.y) end
local sum = Vector.new(1, 2) + Vector.new(3, 4)
print(sum.x .. ", " .. sum.y)4, 6
Dates
Lua has no dates, only seconds since 1970 and os.date. In Sprout a date is a value with its own math (decision 100).
2026-11-20 + 30 print
2026-11-20 weekday print2026-12-20 Friday
local t = os.time({year = 2026, month = 11, day = 20, hour = 12}) + 30 * 86400
print(os.date("!%Y-%m-%d", t))
print(os.date("!%A", os.time({year = 2026, month = 11, day = 20, hour = 12})))2026-12-20 Friday
Money
Lua's numbers are floats, so 0.10 + 0.20 isn't 0.30, and $100 shared three ways loses a cent. Sprout's money is whole cents, and split hands out every one.
$0.10 + $0.20 = $0.30 print
$19.99 * 3 print
$100.00 split 3 printtrue $59.97 [$33.34, $33.33, $33.33]
print(0.10 + 0.20 == 0.30)
print(string.format("$%.2f", 19.99 * 3))
local share = 100 / 3
print(string.format("$%.2f, $%.2f, $%.2f", share, share, share))false $59.97 $33.33, $33.33, $33.33
Unpacking
Lua's multiple assignment unpacks values one by one. Sprout's patterns unpack lists, records and pairs, with ..rest for what's left (decision 101).
[x, y] : 640x480
x * y print
[first, ..rest] : [1, 2, 3, 4]
rest print307200 [2, 3, 4]
local x, y = 640, 480
print(x * y)
local list = {1, 2, 3, 4}
local first, rest = list[1], {table.unpack(list, 2)}
print("[" .. table.concat(rest, ", ") .. "]")307200 [2, 3, 4]
A million random trials
Both estimate pi from a million random points. On this machine Sprout took 19 ms (Node, WebAssembly SIMD) and Lua 5.4 took 72 ms. Counting a million numbers took Sprout 4.3 ms and Lua 13 ms. LuaJIT, where it runs, would be faster than Lua 5.4; it wasn't measured here. Sprout's draws come from a seeded hash, so its answer is the same on every run.
hit : [n | x : noise [n, 1], y : noise [n, 2], x * x + (y * y) < 1 [1] else [0]]
range 1000000 spork hit fold [0, [total h | total + h]] * 4 / 1000000 print3.141792
local hits = 0
for i = 1, 1000000 do
local x, y = math.random(), math.random()
if x * x + y * y < 1 then hits = hits + 1 end
end
print(hits * 4 / 1000000)3.14156
Python 3.13, Clojure 1.12 on Java, and Lua 5.4 through lupa, all on one machine. Run the benchmarks to see Sprout's numbers on your own device.