SultanC

Systems programming,
in Arabic.

SultanC is an Arabic programming language for systems programming. It compiles to native code, and its compiler is written in itself. Write in Arabic or in English: one program, one compiler, and errors in your language.

main.sn
import std.io.println;

def sum(upto: int): int {
    let total: mutable int = 0;
    let n: mutable int = 1;
    while (n <= upto) {
        total := total + n;
        n := n + 1;
    }
    return total;
}

def main(): int {
    println("Hello from SultanC");
    return sum(8);
}
$ sultanc main.sn -o app && ./app Hello from SultanC exit code 36

From source to executable

Arabic and English spellings converge in the lexer. Everything after it works on the same identities: there is no Arabic path and no English path in the semantics.

  1. LexerArabic and English become one token stream
  2. ASTParsing, desugaring, annotations
  3. Names and typesModules, identities, patterns
  4. SafetyOwnership, borrowing and control flow (SSF)
  5. MSIRA target-neutral IR, checked by a verifier
  6. Backend and linkingNative or LLVM, then the compiler's linkers: ELF, Mach-O, PE, Wasm

The stages as in Compiler architecture. MSIR passes a verifier before any backend sees it.

Two languages, one program

Arabic and English keywords are two equal faces of one syntax: the same tree, the same meaning, the same diagnostics. Messages are in Arabic by default, and --lang=en shows them in English.

Take the language tour   All examples (87)

Ownership and borrowing
Every move and borrow is checked before code generation, with no garbage collector.
Exhaustive pattern matching
match rejects the program if you miss a case.
Errors are values
result for success or failure, and ? to pass an error up.
Native output, no libc
ELF, Mach-O, PE/COFF and WebAssembly from the compiler's own linkers, on 38 targets.

Packages with Supax

Supax is the SultanC package manager, written in SultanC. It fetches dependencies from the package index or from git, pins them in Supax.lock so your project builds tomorrow as it built today, and works offline after the first fetch.

Nahr is a web framework written in SultanC, published in the index.

Supax on GitHub

For anyone who wants to learn programming before learning English.

Many people stop at the first line of code because its words are not in their language. SultanC removes that barrier without isolating you: the same program reads in English whenever you want, so you move between the two freely.

Install

git clone https://github.com/sultan-language/sultanc.git cd sultanc ./build.sh --bootstrap=wasm

Linux and macOS. For Windows, FreeBSD and Android: Install SultanC