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.
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);
}
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.
- LexerArabic and English become one token stream
- ASTParsing, desugaring, annotations
- Names and typesModules, identities, patterns
- SafetyOwnership, borrowing and control flow (SSF)
- MSIRA target-neutral IR, checked by a verifier
- 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.
- Ownership and borrowing
- Every move and borrow is checked before code generation, with no garbage collector.
- Exhaustive pattern matching
matchrejects the program if you miss a case.- Errors are values
resultfor 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.
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=wasmLinux and macOS. For Windows, FreeBSD and Android: Install SultanC