Sindarin is a statically-typed procedural programming language that compiles to C. It features clean arrow-based syntax, powerful string interpolation, and built-in array operations.
.sn source → Sn Compiler → C code → GCC/Clang → executable
- Static typing with explicit type annotations
- Arrow syntax (
=>) for clean, readable code blocks - String interpolation with
$"Hello {name}!" - Arrays with built-in operations (push, pop, slice, join, etc.)
- Structs for structured data and C library interop
- String methods (toUpper, toLower, trim, split, splitLines, isBlank, etc.)
- File I/O with TextFile and BinaryFile types
- Control flow with for, for-each, while, match, break, continue
- Module imports for code organization
- Memory semantics with
as ref/as valownership and copy semantics - C interoperability with native functions, pointers, and callbacks
- SDK modules for crypto, networking, JSON/XML/YAML, compression, and more
curl -fsSL https://raw.githubusercontent.com/SindarinSDK/sindarin-compiler/main/scripts/install.sh | bashirm https://raw.githubusercontent.com/SindarinSDK/sindarin-compiler/main/scripts/install.ps1 | iexSee docs/building.md for building from source and other installation options.
# Compile a program
sn samples/main.sn -o myprogram
./myprogram
# Or emit C code only
sn samples/main.sn --emit-c -o output.c
# Emit Rust for a program in the currently supported Rust subset
sn program.sn --target rust --emit-source -o output.rsC remains the default target. The Rust target currently supports primitive
types, functions, local variables, basic control flow, direct calls, arithmetic,
plain value structs (including defaults and nested fields), core array operations,
integer ranges, C-style and array iteration, string interpolation, string
concatenation and copying, common non-mutating string operations, and printing;
unsupported constructs produce a target-specific diagnostic. Rust string methods
currently include contains, startsWith, endsWith, trim, toUpper,
toLower, substring, replace, charAt, and indexOf; length and len(...)
are also supported, and copyOf(string) provides an explicit clone. Concatenation
currently requires string operands, and other string methods are rejected with a
Rust-target diagnostic. Rust interpolation supports printf-style decimal,
hexadecimal, octal, fixed-point, scientific, and string-width specifiers;
unsupported formats and flag combinations are rejected explicitly.
fn is_prime(n: int): bool =>
if n <= 1 =>
return false
var i: int = 2
while i * i <= n =>
if n % i == 0 =>
return false
i = i + 1
return true
fn main(): void =>
var primes: int[] = {}
for var n: int = 2; n <= 50; n++ =>
if is_prime(n) =>
primes.push(n)
print($"Primes: {primes.join(\", \")}\n")
| Document | Description |
|---|---|
| Overview | Language philosophy, syntax overview, examples |
| Building | Build instructions for Linux, macOS, Windows |
| Runtime and package architecture | Shared C runtime ABI, package runtime selection and generated adapters (implementation reference) |
| Native package imports | Generated scalar/string consumer adapters and native archive linking |
| Native backing artifacts | Independent C/Rust/Go archives, metadata, compatibility and cache validation |
| Native package metadata | Backing-language build inputs, binding contracts and ownership metadata |
| Shared runtime ABI | Versioned C value transport, resource ownership and C/Rust/Go client validation |
| Rust completion goal | Required implementation, workflow and acceptance evidence for Rust completion |
| Strings | String methods and interpolation |
| Arrays | Array operations and slicing |
| Structs | Struct declarations and C interop |
| Match | Match expressions for multi-way branching |
| Lambdas | Lambda expressions and closures |
| Memory | Ownership model, as ref/as val semantics, and memory management |
| Threading | Threading with spawn and sync |
| Namespaces | Namespaced imports for collision resolution |
| Interop | C interoperability and native functions |
SDK documentation is available at sindarin-pkg-sdk.
| Document | Description |
|---|---|
| SDK Overview | All SDK modules |
| Crypto | Hashing, encryption, HMAC, PBKDF2, secure random |
| Date | Calendar date operations |
| Time | Time and duration operations |
| Random | Random number generation |
| UUID | UUID generation and manipulation |
| Environment | Environment variable access |
| Process | Process execution and output capture |
| Math | Mathematical functions and constants |
| JSON | JSON parsing and serialization |
| XML | XML parsing, XPath, and DOM manipulation |
| YAML | YAML parsing and serialization |
| ZLib | Compression and decompression |
| Stdio | Standard input/output/error streams |
| File I/O | TextFile, BinaryFile, Path, Directory, Bytes |
| Networking | TCP, UDP, TLS, DTLS, SSH, QUIC |
Source (.sn)
↓
Lexer → Parser → Type Checker → Optimizer → Code Gen → GCC
↓
Executable
See src/ for compiler implementation details.
make test # All tests
make test-unit # Unit tests only
make test-cgen # Code generation tests (compare generated C)
make test-rgen # Rust generation and execution tests
make test-mgen # Model generation tests (compare JSON model)
make test-integration # Integration tests only
make test-integration-errors # Integration error tests
make test-explore # Exploratory tests only
make test-explore-errors # Exploratory error testsOr use the test runner directly (cross-platform):
python3 scripts/run_tests.py all # All tests
python3 scripts/run_tests.py unit # Unit tests
python3 scripts/run_tests.py cgen # Code generation tests
python3 scripts/run_rust_tests.py all # Rust generation, errors and toolchain
python3 scripts/run_tests.py mgen # Model generation tests
python3 scripts/run_tests.py integration # Integration tests
python3 scripts/run_tests.py integration-errors # Integration error tests
python3 scripts/run_tests.py explore # Exploratory tests
python3 scripts/run_tests.py explore-errors # Exploratory error tests├── src/ # Compiler source (lexer, parser, type checker, codegen, runtime)
├── sdk/ # SDK modules (.sn definitions + .c implementations)
├── tests/ # Unit, integration, SDK, and exploratory tests
├── docs/ # Language and SDK documentation
├── samples/ # Example .sn programs
├── scripts/ # Test runner and dependency setup
├── packaging/ # Distribution packaging (deb, rpm, homebrew, winget, arch)
├── benchmark/ # Performance benchmarks
├── bin/ # Compiled outputs (sn compiler, runtime library, SDK)
└── CMakeLists.txt # CMake build configuration
- Fork the repository
- Create a feature branch
- Run tests with
make test - Submit a pull request
MIT License - feel free to use, modify, and distribute!
Named after the Elvish language from Tolkien's legendarium