Soplang Logo
Soplang

Getting Started with Soplang

Install Soplang, write your first program, and learn the core building blocks of the language.

Welcome to Soplang! This guide walks you through installing Soplang, writing your first program, and the core concepts you will use every day.

1. Installation

Download a prebuilt release for your platform from the downloads page, or build it from source with Cargo. Then check that it works:

soplang --version

For all options (installers, Docker, building from source), see the installation guide.

2. Your First Soplang Program

Create a file named hello.sop:

hello.sop
// This is a comment
qor("Salaan, Adduunka!")

// Variables
door magac = "Soplang"
door nooca = 2
qor("Ku soo dhowow " + magac + " " + nooca + "!")

// A simple function
hawl salaam(qof) {
  celi "Salaan, " + qof + "!"
}

qor(salaam("Developer"))

Running Your Program

Open a terminal in the folder where you saved the file and run:

soplang hello.sop

You should see:

Salaan, Adduunka!
Ku soo dhowow Soplang 2!
Salaan, Developer!

Congratulations, you just wrote and ran your first Soplang program. You can also experiment interactively by running soplang with no arguments to open the REPL. See CLI & REPL.

3. Basic Concepts

Variables and Data Types

Soplang supports both dynamic and static typing. Use door for a dynamic variable, or a type keyword (abn, jajab, qoraal, bool, teed, walax) to fix the variable's type.

data_types.sop
// Dynamic (door): the type comes from the value
door magac = "Soplang"
door da = 3

// Static: the type is declared explicitly
abn sanad = 2025
jajab pi = 3.14159
qoraal luqad = "Af-Soomaali"
bool waa_fiican = run
teed luqadaha = ["Soplang", "Python", "Rust"]
walax astaamo = {
  syntax: "nadiif",
  barasho: "fudud"
}

qor(nooc(pi))          // jajab
qor(luqadaha)          // [Soplang, Python, Rust]
qor(astaamo.syntax)    // nadiif

Control Flow

Code blocks are wrapped in curly braces {} and conditions go in parentheses (). Indentation is only for readability.

control_flow.sop
// if / else if / else
abn da = 25
haddii (da < 18) {
  qor("Waad yar tahay")
} haddii_kale (da < 65) {
  qor("Waxaad tahay qof weyn")
} ugudambeyn {
  qor("Waxaad tahay oday")
}

// for loop (the range is inclusive)
teed luqadaha = ["Soplang", "Python", "Rust"]
kuceli (i 0 ilaa dherer(luqadaha) - 1) {
  qor("Waan jeclahay " + luqadaha[i])
}

// while loop
abn tirin = 3
intay (tirin > 0) {
  qor(tirin)
  tirin = tirin - 1
}
qor("Duul!")

Functions

Functions are defined with hawl and return values with celi. Parameters and the return value can optionally be typed.

functions.sop
// Untyped parameters
hawl salaam(magac) {
  celi "Salaan, " + magac + "!"
}

// Typed parameters and return type
hawl isu_gee(abn a, abn b): abn {
  celi a + b
}

qor(salaam("Aamina"))   // Salaan, Aamina!
qor(isu_gee(2, 3))      // 5

Next Steps

On this page