A collection of example programs demonstrating Thorn features. All examples are valid Thorn 0.3 syntax.
write("hello world")
name = "Thorn"
version = 3
write(v"welcome to {name} v0.{version}")
task circleArea(r) {
need math
send math.pi * r * r
}
area = circleArea(5)
write(v"area: {area}")
nums = [1, 2, 3, 4, 5]
loop(n = nums) {
write(v"item: {n}")
}
loop(i = 10) {
write(i) # 0 through 9
}
err = risk {
res = reach("https://api.example.com/data")
send res.json
}
if (err != void) {
write(v"request failed: {err}")
}
need time
need math
task greet(name) {
write(v"hello {name},
it is {now.hour}:{now.minute}")
}
section main {
task run() {
greet("world")
area = math.pi * 5 * 5
write(v"circle area: {area}")
}
}
if (start) {
main()
}
Copyright ©2026 Thorn Language Project. All Rights Reserved