Design Philosophy
Kira is a functional programming language built around three core principles:
- Explicit Types: Every binding must have a type annotation. No type inference.
- Explicit Effects: Side effects are tracked and visible in function signatures.
- No Surprises: One obvious way to do things, predictable behavior.
Why Explicit?
Kira is designed for clarity and predictability, making it ideal for:
- AI code generation — explicit types make generation more reliable
- Teams that value readable, self-documenting code — no hidden behavior
- Applications where side effect tracking matters — I/O boundaries are clear
Explicit Types
In most languages, type inference means you often need to trace through multiple files to understand what a variable holds. In Kira, every binding declares its type:
let x: i32 = 42
let name: string = "Alice"
fn add(a: i32, b: i32) -> i32 { return a + b }This eliminates ambiguity. When reading code, you immediately know the type of every value.
Explicit Effects
Most languages don't distinguish between functions that perform I/O and functions that don't. In Kira, this distinction is first-class:
// Pure — guaranteed no side effects
fn double(n: i32) -> i32 {
return n * 2
}
// Effect — can perform I/O
effect fn greet(name: string) -> void {
std.io.println("Hello, " + name)
}The compiler enforces this: pure functions cannot call effect functions. This means you can trust that a pure function is truly pure.
No Surprises
Kira eliminates common sources of confusion:
- No null — use
Option[T]instead - No exceptions — use
Result[T, E]instead - No implicit conversions — all conversions are explicit
- No undefined behavior — predictable semantics throughout
- Keyword-based logic —
and,or,notinstead of&&,||,! - One way to do things — consistent syntax patterns
Comparison with Other Languages
| Aspect | Traditional Languages | Kira |
|---|---|---|
| Type Annotations | Often optional/inferred | Always explicit and required |
| Side Effects | Hidden, implicit | Tracked in type system |
| Syntax Flexibility | Multiple ways to do the same thing | One obvious way |
| Error Handling | Exceptions, null | Result[T, E] and Option[T] |
| Default Behavior | Pure or impure (unclear) | Pure by default; effects opt-in |