ILMA Language Reference
ILMA is a dynamically-typed, indentation-scoped programming language designed for children and beginners. Every keyword is a plain English phrase. Programs are expressive and readable by design.
This reference covers every feature of the language with complete examples. Each example can be run in the online playground.
Installation
See the full Install page for platform-specific instructions. Quick start:
curl -fsSL https://ilma-lang.dev/install.sh | bash
Hello World
The simplest ILMA program:
say "Assalamu Alaikum, World!"
say — Output
say prints a value to standard output. It accepts any expression, including string interpolation using {variable} inside double quotes.
say "Hello!"
say 42
say 3.14
remember name = "Yusuf"
say "My name is {name}"
say "Two plus two = {2 + 2}"
remember — Variables
remember creates or updates a variable. ILMA is dynamically typed — a variable can hold any type of value.
remember age = 12 remember name = "Bilal" remember pi = 3.14159 remember is_ready = yes remember nothing = empty
Re-assign a variable by writing its name followed by =:
remember score = 0 score = score + 10 say score
ask — User Input
ask prompts the user for input. Numbers are automatically parsed.
remember name = ask "What is your name? "
say "Salaam, {name}!"
remember age = ask "How old are you? "
say "You will be {age + 1} next year."
Comments
Lines starting with # are ignored by the compiler.
# This is a comment remember x = 5 # inline comment too
if / otherwise
Conditional branching uses if, otherwise if, and otherwise. Indentation (4 spaces or 1 tab) defines the block.
remember score = 85
if score >= 90:
say "Excellent!"
otherwise if score >= 70:
say "Good job."
otherwise if score >= 50:
say "Keep trying."
otherwise:
say "Need more practice."
Boolean operators
remember age = 14
remember has_parent = yes
if age < 18 and has_parent:
say "Welcome with your parent!"
if age > 18 or has_parent:
say "Access allowed."
if not has_parent:
say "You need a guardian."
repeat
Run a block of code a fixed number of times.
repeat 5:
say "Bismillah"
keep going while
Loop as long as a condition is true. Maximum 10,000 iterations to prevent infinite loops.
remember count = 1
keep going while count <= 5:
say count
count = count + 1
for each
Iterate over a bag (list) or the characters of a string.
remember fruits = bag["apple", "mango", "date"]
for each fruit in fruits:
say "I like {fruit}"
for each letter in "ILMA":
say letter
check / when — Pattern Matching
check is ILMA's pattern matching statement. Use when for specific values or ranges, and otherwise as a catch-all.
remember grade = 88
check grade:
when 90..100:
say "A — Excellent!"
when 80..89:
say "B — Very Good"
when 70..79:
say "C — Good"
when 60..69:
say "D — Needs Improvement"
otherwise:
say "F — Please study more"
Match multiple values with or:
remember animal = "cat"
check animal:
when "cat" or "dog":
say "Common pet"
when "lion" or "tiger":
say "Wild animal"
otherwise:
say "Unknown animal"
Recipes — Functions
Functions in ILMA are called recipes. Define them with recipe name(params): and call them like any other function.
recipe greet(name, time_of_day):
say "Good {time_of_day}, {name}!"
greet("Yusuf", "morning")
greet("Fatima", "evening")
give back — Return Values
recipe square(n):
give back n * n
recipe is_even(n):
give back n % 2 == 0
say square(7)
say is_even(4)
say is_even(7)
Lambdas (Inline Recipes)
Write short one-line functions with the lambda syntax:
remember double = recipe(x): x * 2 remember square = recipe(x): x * x say double(5) say square(4) remember nums = bag[1, 2, 3, 4, 5] remember doubled = nums.map(recipe(x): x * 2) say doubled
Bags — Lists
A bag is an ordered list of values. Use bag[...] syntax to create one.
remember fruits = bag["apple", "mango", "date", "fig"]
# Access by index
say fruits[0]
# Size
say fruits.size
# Add and remove
fruits.add("grape")
fruits.remove("mango")
# Iterate
for each f in fruits:
say f
# Higher-order methods
remember uppers = fruits.map(recipe(f): f.upper())
say uppers
# Filter
remember long_ones = fruits.filter(recipe(f): length(f) > 4)
say long_ones
# Join
say fruits.join(", ")
Notebooks — Dictionaries
A notebook stores key-value pairs.
remember person = notebook[name: "Yusuf", age: 12, city: "Cairo"]
say person.name
say person.age
say person.size
person.country = "Egypt"
for each key in person.keys():
say key
Blueprints — Classes
Blueprints define the structure and behaviour of objects. Use me to refer to the current instance (like self in Python).
blueprint Animal:
recipe setup(name, sound):
me.name = name
me.sound = sound
recipe speak():
say "{me.name} says {me.sound}!"
remember cat = Animal("Cat", "meow")
remember dog = Animal("Dog", "woof")
cat.speak()
dog.speak()
comes from — Inheritance
blueprint Pet comes from Animal:
recipe setup(name, sound, owner):
Animal.setup(me, name, sound)
me.owner = owner
recipe info():
say "{me.name} belongs to {me.owner}"
remember my_cat = Pet("Luna", "meow", "Yusuf")
my_cat.speak()
my_cat.info()
try / when wrong — Error Handling
Wrap risky code in try: and catch errors with when wrong:. The error variable is automatically set to the error message.
try:
remember result = 10 / 0
when wrong:
say "Something went wrong: {error}"
say "Using default value of 0 instead."
remember result = 0
say "Result is: {result}"
shout — Raise Errors
Use shout to raise an error intentionally.
recipe divide(a, b):
if b == 0:
shout "Cannot divide by zero!"
give back a / b
try:
say divide(10, 0)
when wrong:
say "Caught: {error}"
Standard Library — number
use number say number.sqrt(16) # 4 say number.abs(-7) # 7 say number.round(3.7) # 4 say number.floor(3.9) # 3 say number.ceil(3.1) # 4 say number.is_prime(17) # yes say number.fibonacci(10) # 55
Standard Library — science
use science remember mass = 10 say science.gravity(mass) # 98.1 N say science.celsius_to_fahrenheit(100) # 212 say science.celsius_to_kelvin(0) # 273.15 say science.speed(100, 2) # 50 m/s say science.kinetic_energy(2, 10) # 100 J
Standard Library — finance
use finance remember wealth = 10000 remember nisab = 595 say finance.zakat(wealth, nisab) # 250 (2.5%) say finance.compound(1000, 5, 3) # 1157.63 say finance.simple_interest(1000, 5, 2) # 100 say finance.profit(800, 1200) # 400 say finance.margin(800, 1200) # 33.33%
Standard Library — body
use body remember weight = 70 # kg remember height = 1.75 # metres say body.bmi(weight, height) # 22.86 say body.daily_water(weight) # 2.31 litres
Standard Library — trade
use trade say trade.profit(400, 600) # 200 say trade.margin(400, 600) # 33.33% say trade.discount(100, 20) # 80 (20% off) say trade.vat(100, 15) # 115 (15% VAT)
Package Manager
Install packages from the ILMA registry with ilma get:
ilma get quran-data
Then use the package in your code:
use quran_data remember surah = quran_data.get_surah(1) say surah.name say surah.ayah_count
Publish a package you created:
ilma publish
Toolchain Reference
# Compile and run ilma run hello.ilma # Build native binary ilma build hello.ilma -o hello # Format code ilma fmt hello.ilma ilma fmt . # whole project # Type check ilma check hello.ilma # Run tests ilma test # Start REPL ilma repl # Generate docs ilma doc # Start language server ilma lsp
Something missing? Open an issue on GitHub or start a discussion. ILMA is open source and community-driven.