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.cfn 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 |
| 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-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_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