A taste
fun fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1)
+ fibonacci(n - 2);
}
print fibonacci(10);
var multiply = fun(a, b) {
return a * b;
};
print multiply(3, 4);
// IIFE
print fun(x) { return x * x; }(5);class Animal {
init(name) {
this.name = name;
}
}
class Dog < Animal {
init(name){
super.init(name);
}
speak() {
print this.name + " barks";
}
}
var rex = Dog("Rex");
rex.speak();import "math" as m;
print m.pi;
print m.pow(2, 3);
// easy to use modules
// for code organizationWhat you get
○
Classes & inheritance — define methods and reuse behavior via single inheritance
○
Functions — named functions with lexical scoping
○
Closures — functions capture surrounding lexical scope
○
Module system — file-based modules with explicit exports and alias-based imports
○
Const bindings — immutable names when you want them
○
Arrays & hashes — built-in indexed and key-value data structures