Nimble is indentation‑sensitive with a minimal, Python‑like syntax.
# This is a single‑line comment. No block comments.Variables are mutable by default. Type annotation is optional.
x = 10 # Inferred int
name = "Nimble" # Inferred str
pi float = 3.14 # Explicit float
active bool = true # Explicit boolPrimitive types:
int(64‑bit)float(64‑bit)strboolnull
Compound types:
- Lists:
[T] - Maps:
{K: V} - Unions:
A | B
Example:
items [int] = [1, 2, 3]
meta {str: str} = {"id": "123"}
result int | error = safe_divide(10, 2)?Use {expr} inside strings. To render literal braces, use {{ and }}.
name = "Nimble"
out("Hello, {name}!")if x > 10:
out("Greater")
elif x == 10:
out("Equal")
else:
out("Smaller")label = "adult" if age >= 18 else "minor"for i in 0..10:
out(i)for i in 0..10 step 2:
out(i)for item in [1, 2, 3]:
out(item)
for key, val in {"a": 1}:
out("{key}: {val}")while x > 0:
x -= 1Defined with the fn keyword.
fn add(a int, b int) -> int:
return a + b
# Short syntax
fn square(x int) -> int = x * xspawn fn():
out("Async task")cls defines a data structure. Fields require types.
cls User:
name str
age int
user = User(name="Alice", age=30)
out(user.name)Errors are values. Use | error for fallible return types and ? for propagation.
fn check(n int) -> int | error:
if n < 0: return error("Negative")
return n
val = check(-1)?Use load to import modules and export to make symbols public.
load math
load utils from "./local_utils"
export fn add(a int, b int) -> int:
return a + b