SUB — Simple Universal Builder
A small language toolchain: one .sb source, compiled to native x86-64
machine code, interpreted live, or transpiled to 13 languages.
curl -fsSL https://raw.githubusercontent.com/subhobhai943/sub-lang/main/installer/install.sh | sh
Features
Three tools in one toolchain. Real compilation, real interpretation, real transpilation — no wrappers.
Native compiler — subc
Emits x86-64 machine code and writes the ELF executable itself. No assembler, no linker, no libc — a compiled SUB program is a self-contained static binary a few kilobytes in size.
Direct interpreter — subi
Runs .sb programs instantly, with an interactive REPL. The interpreter is the specification every backend agrees with, and CI diffs each backend against it.
13-target transpiler — sub
One command generates idiomatic Python, JavaScript, TypeScript, C, C++, Rust, Go, Java, Kotlin, Swift, Ruby, x86-64 Assembly, and CSS from a single AST.
Classes & objects
Clean OOP with class, fields, .new construction and member access — lowered idiomatically on every backend.
Pattern matching
switch/case over ints, strings and floats with multi-value clauses and no fall-through — a case runs its body and nothing else.
Standard library
Four modules — math, arrays, strings, io — written in SUB, verified through every backend, loaded with import.
Declarative UI tree
First-class ui.* syntax for windows, labels, buttons and inputs — one tree, many renderers.
Packages everywhere
Windows .msi, Linux .deb/.rpm, macOS .pkg, FreeBSD pkg, Arch, Alpine, AppImage — and a universal curl | sh.
Download
Direct links to the latest release. Your platform has been highlighted.
Code examples
One canonical spelling: let, fn, null, brace-delimited blocks. Older spellings still compile, with a deprecation note.
let name = "World"
let greeting = "Hello, " + name
println(greeting)
fn add(a, b) {
return a + b
}
println(add(10, 20))
let choice = 2
switch choice {
case 1:
println("First choice")
case 2, 3: # one clause, several values
println("Second choice")
default:
println("Other choice")
}
class Point {
let x = 0
let y = 0
}
let p = Point.new
p.x = 10
p.y = 20
println(p.x) # 10
println(p.y) # 20
Transpilation targets
Ten of the thirteen targets are executed and diffed against the interpreter in CI, on every push.
- Pythonverified in CI
- JavaScriptverified in CI
- TypeScriptverified in CI
- Cverified in CI
- C++verified in CI
- Rustverified in CI
- Goverified in CI
- Javaverified in CI
- Kotlinverified in CI
- Swiftverified in CI
- Rubyverified in CI
- x86-64 Assemblygenerated
- CSSgenerated
$ sub program.sb rust # -> program.rs
$ sub program.sb go # -> program.go
$ sub program.sb python # -> program.py
Quick start
Up and running in under a minute.
-
Install
Grab a release for your platform, or use the universal installer:
curl -fsSL https://raw.githubusercontent.com/subhobhai943/sub-lang/main/installer/install.sh | shOr build from source:
make. -
Run it
Interpret a script, or drop into the REPL:
$ echo 'println("hello")' > hello.sb $ subi hello.sb hello -
Go native
Compile straight to machine code, or out to any target:
$ subc hello.sb -o hello $ ./hello $ sub hello.sb rust