Kiwi Language
Kiwi is a clean, expressive, and modern programming language with a .kiwi file extension. Designed to be readable and fun to write — not a clone of anything.
Install the Interpreter
pip install kiwi-lang
Then run any .kiwi file:
kiwi hello.kiwi
kiwi # opens the REPL
What makes Kiwi different
| Kiwi |
Other languages |
show "hello" |
print("hello") |
give result |
return result |
unless x > 10 { } |
if not (x > 10): |
repeat 5 times { } |
for _ in range(5): |
each item in list { } |
for item in list: |
forever { } |
while True: |
value \|> transform |
transform(value) |
name ? "default" |
name if name else "default" |
Syntax
// Variables — let is immutable, mut is mutable
let name = "Kiwi"
mut score = 0
// String interpolation
show $"Hello from {name}!"
// Functions
fn factorial(n) {
if n <= 1 { give 1 }
give n * factorial(n - 1)
}
show factorial(10) // 3628800
// Arrow shorthand
fn double(x) => x * 2
fn greet(n) => $"Hey, {n}!"
// unless — cleaner than if not
unless score > 0 {
show "No points yet."
}
// repeat
repeat 3 times {
show "Kiwi!"
}
// each
let fruits = ["apple", "mango", "kiwi"]
each fruit in fruits {
show $" {fruit}"
}
// forever loop
mut i = 0
forever {
i += 1
if i >= 5 { break }
}
// Pipe operator |>
fn square(x) => x * x
fn big(x) => x > 20
let nums = [1, 2, 3, 4, 5, 6, 7, 8]
let result = nums
|> fn(l) => l.map(square)
|> fn(l) => l.filter(big)
show result // [25, 36, 49, 64]
// Null coalescing ?
mut username = null
show username ? "Guest" // Guest
username = "melih"
show username ? "Guest" // melih
// give — return alternative
fn clamp(val, lo, hi) {
if val < lo { give lo }
if val > hi { give hi }
give val
}
// Match
let day = 3
match day {
1 => show "Monday"
2 => show "Tuesday"
3 => show "Wednesday"
_ => show "Other"
}
// List methods
nums.push(9)
nums.sort()
let squares = nums.map(fn(x) => x * x)
let evens = nums.filter(fn(x) => x % 2 == 0)
show squares
show evens
// Math
show 2 ** 10 // 1024
show sqrt(144) // 12
show abs(-7) // 7
show round(3.14159, 2) // 3.14
Built-in Functions
show · input · len · int · float · str · bool · type
range · abs · max · min · round · floor · ceil · sqrt
random · randint · sleep · exit
Language Basics
- Immutable by default — use
let. Use mut to allow reassignment.
- No semicolons — newlines end statements.
- Curly braces
{} for all blocks.
- First-class functions — pass them, store them, pipe them.
give is return. Both work.
show is print. Both work.
File Extension
.kiwi — this extension provides full syntax highlighting and file icons for VS Code.
Links
Created by Melih Yazar