English | ๆฅๆฌ่ช
๐ฆ ARC memory safety ยท โก Cranelift JIT ยท ๐ C FFI ยท ๐ฎ ships with an SDL2 game demo
A compiler/runtime for ilang, a young programming language under active design. Tree-walking interpreter for fast feedback, Cranelift JIT for performance, and a Rust-flavoured surface syntax that talks to C libraries when you need to.
fn fib(n: i64): i64 {
if n < 2 { n } else { fib(n - 1) + fib(n - 2) }
}
console.log(fib(20)) // โ 6765- ๐ก๏ธ Capability-based security โ libraries and classes carry
permissions like
net,file; the host grants them at use sites to reduce supply-chain blast radius. (annotations parse today; enforcement is the next big milestone) - ๐ฆ ARC for memory safety โ no ownership /
mut/ borrow checker. - ๐ฆ Rust-flavoured declarations and type names.
- ๐ C / JavaScript arithmetic semantics (operator precedence, integer-promotion behaviour).
The implemented syntax / types / built-ins are catalogued in docs/syntax.md.
| Category | Status |
|---|---|
Numeric types (i8โi64 / u8โu64 / f32 / f64) + as casts |
โ |
bool / comparison / short-circuit logic |
โ |
let / assignment / compound assignment (+= and friends) |
โ |
Control flow (if / else / while / loop / break / continue / early return) |
โ |
| Strings / arrays (dynamic & fixed-length) | โ |
class / new / init / this / deinit (JS-style) |
โ |
Inheritance (extends / super) + virtual dispatch |
โ |
console.log |
โ |
Optional (T? / some / none / if let) |
โ |
Weak references (T.weak / .get()) |
โ |
enum + match (with built-in Result<T, E>) |
โ |
Map<K, V> / Tuple |
โ |
| Closures (with capture) | โ |
| Generics (functions / classes / enums) | โ |
| Function overloading | โ |
| ARC-based memory management | โ |
| Type checking | โ |
Cranelift JIT (ilang run --jit) |
โ |
FFI (@extern(C) {} blocks calling C libraries) |
โ |
| Capability annotations | ๐ง parse-only |
No ownership / mut / borrow checker โ every variable is
reassignable. Errors are emitted in the uniform
filename [row:col]: message format.
ilang is implemented in Rust, so you'll need a Rust toolchain (rustup / cargo). If it isn't installed, grab it from https://rustup.rs:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shClone the repo:
git clone https://github.com/iwao0/ilang
cd ilang
cargo build # first run resolves deps + compiles (~1 minute)# ๐ฌ REPL โ let / fn persist across lines, interpreter mode
cargo run -p ilang-cli
# ๐ Run a file (`;` is optional, newlines act as statement separators
# JS-ASI style)
cargo run -p ilang-cli -- run path/to/script.il
# โก Run via the JIT (Cranelift native code โ tens to hundreds of times
# faster than the interpreter)
cargo run -p ilang-cli -- run --jit path/to/script.ilCode that calls into a C library through @extern(C) {} (the SDL2
sample below, for example) is JIT-only. Symbols are resolved
through dlsym at JIT-build time, so the interpreter has no path to
those functions.
cat > sample.il <<'EOF'
fn count_div(n: i64): i64 {
let i = 1
let count = 0
while i <= n {
if i % 3 == 0 || i % 5 == 0 {
count = count + 1
}
i = i + 1
}
count
}
count_div(100)
EOF
cargo run -p ilang-cli -- run sample.il # => 47JS-flavoured objects with class / new / init (constructor) /
this. Inside method bodies you can omit this. for fields and
methods (a local or parameter of the same name still wins).
cat > counter.il <<'EOF'
class Counter {
count: i64
init(start: i64) { this.count = start }
bump(): i64 {
count += 1 // same as `this.count += 1`
count
}
}
let c = new Counter(10)
let i = 0
loop {
if i >= 5 { break }
c.bump()
i += 1
}
c.bump()
EOF
cargo run -p ilang-cli -- run counter.il # => 16examples/sdl_breakout/ contains an SDL2 demo: a neon-style
breakout game with paddle, bricks, particles, and gamepad support.
Arrow keys / A D (or D-pad / left stick) move the paddle,
Space launches the ball, F toggles fullscreen, R restarts
after game over, ESC quits.
Install SDL2 first:
# ๐ macOS (Homebrew)
brew install sdl2
# ๐ง Debian/Ubuntu
sudo apt install libsdl2-dev libsdl2-2.0-0Run:
cargo run -p ilang-cli -- run --jit examples/sdl_breakout/main.ilThe sample pulls in the SDL2 bindings under bindings/sdl2/ via a
plain use sdl. The mechanism (an ilang.toml with a [deps]
table) is documented in
bindings/sdl2/README.md.
To use the SDL2 bindings from your own project, drop an
ilang.toml next to (or above) your entry file:
[package]
name = "my_game"
[deps]
sdl2 = "/path/to/ilang/bindings/sdl2"The CLI walks upward from the entry file looking for ilang.toml
at startup; each [deps] value becomes an additional search
directory for use module resolution.
vscode-extension/ ships syntax highlighting plus a language
server (ilang-lsp) for diagnostics, hover, and go-to-definition.
Local install:
# 1. Build the language server
cargo build -p ilang-lsp
# 2. Build the extension client
cd vscode-extension
npm install
npm run compile
# 3. Symlink into VSCode's extensions directory
ln -s "$(pwd)" ~/.vscode/extensions/ilangRestart VSCode. See
vscode-extension/README.md for
configuration (ilang.serverPath) and current limitations.
Run the whole test suite โ Rust unit tests across every crate plus
the language-level fixtures under
crates/ilang-cli/tests/programs/ (each .il fixture is executed
in both the interpreter and the JIT, with expect: / expect-error:
magic comments asserting the outcome):
cargo test --workspaceMIT OR Apache-2.0