A simple, dynamically typed programming language for teaching
Hanling is a minimalist programming language designed for teaching. It features clean syntax, built-in contracts (require / ensure), and language-level unit tests (test blocks). The interpreter is a single Go binary — no dependencies, no setup.
print("Hello, World!")
x = 10
y = 3
print(x + y) # 13
print(x / y) # 3.3333...
if score >= 90 then
print("A")
elseif score >= 80 then
print("B")
else
print("C")
end
for i in range(5) do
print(i)
end
function factorial(n)
require n >= 0
if n <= 1 then
return 1
end
return n * factorial(n - 1)
ensure result > 0
end
print(factorial(5)) # 120
nums = [1, 2, 3]
append(nums, 4)
print(nums) # [1, 2, 3, 4]
person = {"name": "Alice", "age": 30}
print(person["name"]) # Alice
function make_adder(x)
function adder(n)
return x + n
end
return adder
end
add5 = make_adder(5)
print(add5(3)) # 8
try
num = int("abc")
catch e
print("Failed: " + e)
end
function add(a, b)
return a + b
end
test "addition works"
assert(add(2, 3) == 5)
assert(add(-1, 1) == 0)
end
Clean syntax — blocks end with end
Dynamic types — numbers, strings, booleans, nil, lists, maps
First-class functions — closures & higher-order functions
Design by Contract — require / ensure
Built-in unit tests — test blocks + assert
50+ built-in functions — math, strings, I/O, etc.
Cross-platform — single Go binary, no dependencies
GPL3.0 licensed