Sage
July 10, 2026 · View on GitHub
A clean, indentation-based systems programming language built in C.

Sage is a systems programming language that combines the readability of Python (indentation blocks, clean syntax) with the performance of C. It features ten execution backends (C, LLVM IR, native x86-64/aarch64/rv64/mips, bytecode VM, SageMetal VM, JIT, AOT, Kotlin/Android), a self-hosted interpreter with hybrid JIT/AOT profile-guided type specialization, Vulkan + OpenGL graphics, true atomic operations and POSIX semaphores for multicore concurrency, and three GC modes (tracing, ARC, ORC).
Current version: v4.0.3 · Spec version: 2.0 · License: MIT
Recent Updates
- OIS v2.0 Overhaul: Installer rewritten with CMake-first default,
--cmake/--makeoverride flags,--no-lib-<name>to exclude specific lib subdirectories,--no-shadersto skip GLSL→SPIR-V compilation,--no-vulkan/--no-gpu/--no-curl/--no-ssl/--minimalflags, system-scope only, POSIX-sh compliance,--yesnon-interactive mode, and removed user-scope support.
Install (One-line Install System — OIS v2)
git clone https://github.com/Night-Traders-Dev/SageLang.git && cd SageLang && sh install.sh
OIS v2 is a POSIX-sh build and install system. It handles environment detection,
dependency installation (CURL, OpenSSL, Vulkan, GLSL shader compiler), and
installs Sage system-wide under /usr/local.
Usage
sh OIS/OIS.sh install|uninstall|repair|reinstall [options]
Options:
--cmake Use CMake (default when available)
--make Force Make build
--yes, -y Non-interactive mode
--no-shaders Skip GLSL→SPIR-V shader compilation
--no-vulkan Disable Vulkan support
--no-gpu Disable GPU graphics
--no-curl Disable networking (CURL)
--no-ssl Disable SSL/TLS
--no-lib-<name> Exclude a lib subdirectory (e.g. --no-lib-ml)
--minimal Exclude all optional libs + Vulkan + networking
| Platform | Package Manager | Notes |
|---|---|---|
| Linux | apt, pacman, dnf, yum, zypper, apk, emerge, xbps | Full support |
| macOS | Homebrew or MacPorts | Auto-installs either if needed (pending) |
| FreeBSD | pkg | Native BSD-Make support |
| WSL2 | (same as Linux) | No differences from Linux |
Quick Example
import math
print math.sqrt(16) # 4
import http
let resp = http.get("https://example.com")
if resp != nil:
print resp["status"] # 200
async proc compute(x):
return x * x
let future = compute(42)
print await future # 1764
Building
make clean && make -j$(nproc) # produces ./sage and ./sage-lsp
Desktop build links against libm, pthread, dl, libcurl, and OpenSSL.
Desktop build links against libm, pthread, dl, libcurl, and OpenSSL.
All execution backends share robust generator support with cooperative multitasking via yield and next() functions, enabling non-blocking operations and efficient pausing/resumption of execution within procedures.
Refreshed by make charts and as part of the default make build (count
authored, non-empty tracked lines; exclude vendored deps and build artifacts).
Cross-Backend Comparison
Run python3 scripts/generate_backend_chart.py or
bash benchmarks/run_backend_compare.sh to regenerate (8 workloads across all
native backends).
Recipe Benchmarks
Generated from python3 scripts/benchmark_recipes.py --runs 5 --warmups 1
against benchmarks/runtime_compare.sage. Run make benchmark-python to
compare all Sage backends against CPython 3.x on 10 workloads.
Features (Implemented)
Detailed feature documentation lives under core/docs/. This section is a summary with links to the relevant guide.
Language & Core
- Indentation-based syntax — no braces; clean, consistent indentation
- Variables —
letandvarfor bindings (both allow reassignment in current spec) - Types — Integers, Strings, Booleans, Nil, Arrays, Dictionaries, Tuples, Classes, Instances, Exceptions, Generators, Bytes
- Functions —
proc name(args):with recursion, closures, first-class functions, inline anonymous proc expressions (proc(x): body end) - Control flow —
if/else,while,for,break,continue,try/catch/finally,match/case/default,defer - Operators — arithmetic, comparison, logical (
and/or), bitwise (&/|/^/~/<</>>), unary - v2.0 enhancements — type annotations,
sage check, structs, enums, traits, match guards, default params, multiline literals, escape sequences, hex/octal/binary literals,superauto-self, dunder hooks (__str__/__eq__), bytes type,unsafeblocks, doc comments (##), path/hash builtins,elif,varkeyword - Metaprogramming —
comptime:blocks,comptime()expressions, pragmas (@inline/@packed/@section/@align/@deprecated/@noreturn), AST macros, generics (proc identity[T](x: T) -> T:)
📖 SageLang Guide · Import Semantics · Stability Policy
Execution Backends & Compilers
C codegen, LLVM IR (--compile-llvm), native assembly (x86-64/aarch64/rv64/mips),
bytecode VM, SageMetal VM, JIT, AOT, and Kotlin/Android — 10 backends total.
📖 JIT & AOT Guide · CLI Reference · SGVM Guide · Android Guide
Memory Management
Three GC modes: concurrent tri-color mark-sweep (default, SATB write barriers, sub-ms STW), ARC (deterministic reference counting), and ORC (optimized RC with Lins' trial deletion cycle collector).
📖 GC Guide
Concurrency
Threads, async/await, true __atomic operations, POSIX semaphores,
condition variables, read-write locks, and SMP/hyperthreading detection with
core affinity.
Security
Type-safe value access, recursion/loop/string-length limits (100MB I/O limit), abort-on-OOM allocations, shell-injection prevention, FFI bounds, memory safety, and bitwise shift validation.
📖 Safety Guide · Security Policy
Standard Library
110+ native functions plus a modern Sage standard library (lib/std/): regex,
datetime, log, argparse, compress, unicode, fmt, testing, enum, trait, signal,
db, channel, threadpool, atomic, rwlock, condvar, debug, profiler, docgen,
build, interop. Native modules: math, io, string, sys, thread, fat,
socket, tcp, http, ssl. JSON via a complete 1:1 cJSON port.
📖 StdLib Guide · Networking Guide
OS Development
44 binary-format parsers, hardware abstraction, boot, kernel, filesystem, image,
Linux kernel support, and QEMU virtualization modules for bare-metal, UEFI, and
OS kernel development under lib/os/. Bare-metal C runtime for --compile-bare
and --compile-uefi.
📖 Bare-Metal / OSdev / UEFI Guide · FAT Filesystem Guide
GPU Graphics Engine (Vulkan + OpenGL)
Full Vulkan backend with handle-based resource management, OpenGL 4.5+ backend, LLVM-compiled GPU support, bytecode VM GPU opcodes, and professional rendering libraries (PBR, shadows, deferred, SSAO, SSR, TAA, glTF, frame graph).
Machine Learning & LLMs
Tensors, neural networks, optimizers, GPU acceleration (cuBLAS), NPU backends (Hexagon/Exynos/NNAPI/NEON), CUDA library, and a full LLM toolkit (transformers, quantization, TurboQuant, GGUF, training pipeline, evolve).
Agent AI & Chatbots
ReAct agent loop, planner, sandbox, Tree of Thoughts, critic, router, supervisor, grammar-constrained decoding, and a chatbot framework with personas.
Blockchain & Cryptography
Pure-Sage enterprise L1 blockchain (SageChain) with smart contracts, NFTs, PoW/PoA consensus, wallet, RPC, and P2P. Cryptographic suite: SHA-256, HMAC, Base64, RC4, PBKDF2, xoshiro256** PRNG, UUID.
📖 Blockchain · Cryptography Guide
Discord Bots
Gateway and REST API support for building Discord bots, mirroring Python's
discord and discord.ext libraries.
Developer Tooling
REPL, code formatter, linter, syntax highlighting (TextMate + VSCode), and an LSP server with diagnostics, completion, hover, and formatting.
📖 Tooling Guide · CLI Reference
Self-Hosting
Sage can run Sage through a self-hosted interpreter written entirely in SageLang (lexer, parser, interpreter, compiler toolchain ported from C to Sage).
Roadmap
All 18 development phases are complete (core logic, functions, types, GC, data structures, OOP, control flow, modules, security/perf hardening, low-level programming, compiler, concurrency, tooling, self-hosting, security audit, Vulkan graphics, Linux kernel support, and ML/training).
📝 Detailed Roadmap · Changelog · Benchmarks
Project Stats
- Phases Completed: 18/18 (100%)
- Test Suite: 2070+ total (331 interpreter + 28 compiler + 88 JSON + 1623 self-hosted)
- Backends: 10 (C, LLVM, native x86-64/aarch64/rv64/mips, bytecode VM, SageMetal VM, JIT, AOT, Kotlin/Android)
- Self-Hosting: Lexer, parser, interpreter, formatter, linter, LSP, codegen, compiler ported to Sage
- Status: Specification locked (v2.0)
- License: MIT
Contributing
Sage is an educational project aimed at understanding compiler construction and language design. Contributions are welcome!
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Follow the existing code style, add comments for complex logic, update documentation for new features, and write example code demonstrating new features. See the templates/ directory for library scaffolding.
Resources
- Repository: github.com/Night-Traders-Dev/SageLang
- Documentation: core/docs/ · Language Book · Language Reference
- Issues: GitHub Issues
- Discussions: GitHub Discussions
License
Distributed under the MIT License. See LICENSE for more information.