Skip to main content
Kira

Basics

Kira has explicit types everywhere. Every binding must have a type annotation.

Variables

let x: i32 = 42           // Immutable binding
var y: i32 = 0             // Mutable binding
y = 10                     // Reassignment (only for var)
  • let creates an immutable binding — it cannot be reassigned
  • var creates a mutable binding — it can be reassigned

Numeric Types

// Signed integers
let a: i8 = 127
let b: i16 = 32000
let c: i32 = 42
let d: i64 = 1000000
let e: i128 = 170141183460469231731687303715884105727

// Unsigned integers
let f: u8 = 255
let g: u16 = 65535
let h: u32 = 4294967295
let i: u64 = 18446744073709551615

// Floating point
let pi: f32 = 3.14159
let precise_pi: f64 = 3.141592653589793

// Integer literals with underscores for readability
let million: i32 = 1_000_000

// Different bases
let hex: i32 = 0xff        // 255 in decimal
let binary: i32 = 0b1010   // 10 in decimal

// Type suffixes
let explicit: i64 = 42i64
let float32: f32 = 3.14f32

Boolean and Character Types

let flag: bool = true
let is_ready: bool = false

let letter: char = 'A'
let emoji: char = '🎉'

Strings

let greeting: string = "Hello, World!"
let multiline: string = "Line 1\nLine 2\nLine 3"

// Escape sequences
let escaped: string = "Tab:\tNewline:\nQuote:\""

String Interpolation

Strings can contain embedded expressions using ${expr} syntax:

let name: string = "Alice"
let age: i32 = 30
let message: string = "Hello, ${name}! You are ${age} years old."
// → "Hello, Alice! You are 30 years old."

Rules:

  • Any expression is allowed inside ${}, including arithmetic and function calls
  • Values are converted to strings automatically
  • Use \$ to include a literal dollar sign: "Price: \$${price}"
  • The result type is always string

Tuples

Tuples are fixed-size collections of heterogeneous values:

let pair: (i32, string) = (42, "hello")
let triple: (i32, bool, f64) = (1, true, 3.14)

// Access tuple elements by index
let first: i32 = pair.0      // 42
let second: string = pair.1  // "hello"

Arrays

Arrays have a fixed size known at compile time:

let numbers: [i32; 5] = [1, 2, 3, 4, 5]
let zeroes: [i32; 3] = [0, 0, 0]