Official documentation

SwahiliPro programming language documentation

Learn how to write SwahiliPro v2 programs with familiar programming structure and human-readable Swahili commands. This reference covers the language basics, the swa CLI and the VS Code workflow.

Getting started

Create a file ending in .swa, write your program, then run it with the standalone SwahiliPro CLI.

# hello.swa
andika("Habari Dunia!")
$ swa hello.swa

You can also install the SwahiliPro VS Code extension for language support and run commands from the editor.

Variables with acha

Use acha to bind values. Variables can hold numbers, text, lists and other supported values.

acha jina = "Amina"
acha umri = 24
acha miji = ["Nairobi", "Mombasa"]

Conditions with ikiwa and vinginevyo

Conditions use braces, keeping block structure familiar while the readable commands remain Swahili.

acha umri = 20

ikiwa (umri >= 18) {
  andika("Karibu")
} vinginevyo {
  andika("Bado mdogo")
}

Loops with kwa and wakati

Use kwa ... katika to iterate through a collection or an end-exclusive range. Use wakati for while-style loops.

kwa i katika 1..5 {
  andika(i)
}

Functions and rudisha

Functions do not require a separate function keyword. Name the function, declare parameters and use rudisha when a value should be returned.

jumlisha(a, b) {
  rudisha a + b
}

andika(jumlisha(2, 3))

Lists and indexing

Lists use familiar bracket syntax and conventional zero-based indexing.

acha lugha = ["SwahiliPro", "Python", "JavaScript"]
andika(lugha[0])
ongeza(lugha, "Go")

Logic and booleans

Use na, au and sio for boolean logic. Boolean values are kweli and uongo.

acha ana_kitambulisho = kweli
acha umri = 25

ikiwa (umri >= 18 na ana_kitambulisho) {
  andika("Unaweza kuingia")
}

Standalone swa CLI

The standalone CLI runs SwahiliPro files directly and can also open the interactive REPL.

swa hello.swa
swa
swa repl
swa --version
swa --help
Download the standalone CLI

VS Code extension

The SwahiliPro extension adds language recognition, syntax highlighting, Run File, Open REPL and editor actions for .swa files.

Install from VS Code Marketplace