Skip to main content
Kira

Hello World

Create a file called hello.ki:

// hello.ki - Your first Kira program

effect fn main() -> void {
    std.io.println("Hello, Kira!")
}

Run it:

kira run hello.ki

Output:

Hello, Kira!

Breaking It Down

  • effect fn main() declares an effect function named main
  • -> void means it returns nothing
  • std.io.println is a standard library function for printing
  • The effect keyword indicates this function performs side effects (I/O)

A More Interesting Example

Here's a program that demonstrates several Kira features:

type Shape =
    | Circle(f64)
    | Rectangle(f64, f64)

fn area(shape: Shape) -> f64 {
    var result: f64 = 0.0
    match shape {
        Circle(r) => { result = 3.14159 * r * r }
        Rectangle(w, h) => { result = w * h }
    }
    return result
}

effect fn main() -> void {
    let circle: Shape = Circle(5.0)
    let rect: Shape = Rectangle(3.0, 4.0)

    std.io.println("Circle area: " + to_string(area(circle)))
    std.io.println("Rectangle area: " + to_string(area(rect)))
}

This demonstrates:

  • Sum types (Shape with variants Circle and Rectangle)
  • Pattern matching to handle each variant
  • Pure functions (area has no side effects)
  • Effect functions (main performs I/O)
  • Explicit types on every binding

Next Steps