Language reference · Section 1
Design principles
- Easy to write comes first. One clear way to do each thing. When two designs are equally powerful, the one a beginner reads correctly wins.
- Safe by default. No null crashes, no out-of-bounds reads, no integer wrap-around, no data races, no use-after-free. Mistakes are errors with a location and a hint, preferably before the program runs.
- Predictable memory. Values are freed the moment they are no longer used. There is no garbage-collector pause and no manual freeing.
- Small. Every feature earns its place.
A first program:
drop("Hello, world!")A taste of most of the language:
seed math
root GREETING = "Hello"
tree Planet {
name: str
radius_km: float
branch area() -> float {
return 4.0 * math.PI * self.radius_km ** 2
}
}
plant planets = [Planet("Mercury", 2439.7), Planet("Earth", 6371.0)]
for p in planets {
drop("{}, {}! Surface: {} km²")
}