Skip to content
warpy-aiPublic

About

Unroll a new functional programming language

Resources

Code of conduct

Contributing

Stars

81 stars

Watchers

2 watching

Forks

Repository files navigation

Oite

/ˈɔɪ.tʲə/

A high-performance JavaScript-like scripting language with native code execution

Featuring a self-hosting compiler and Rust-inspired memory safety


Rust 1.70+ Status: pre-alpha Self-Hosting: partial License

TL;DR

This project is AI assisted, with some chunks of the code being generated by AI, marjority of the code still were generated by a Human, mainly the buggy part, and inconsistent functions. Most of the documentation were generate by AI , documentation will be properly addressed when the project gets more mature.

This project accepts and encourage AI to be used. If you're against AI please consider contributing to another project.

Overview

Oite (pronouce oy-tee) is a scripting language that combines JavaScript-like syntax with Rust-inspired memory safety and native code performance.

function fib(n) {
  if (n < 2) return n;
  return fib(n - 1) + fib(n - 2);
}

console.log(fib(35)); // Compiled to native code!

Key Features

Status: pre-alpha. The list below is the design. Native code is the target: the JIT and AOT backends run the same language features as the VM (the debugging interpreter), modules included. Generators, regular expressions and tagged templates are compile errors on every backend, and the require, fs, JSON, fetch, process and ByteStream globals exist only in the VM. Type annotations are checked as warnings for now, and memory is never freed. See Development Status for what runs on which backend, and #136 for the roadmap.

  • Native Execution — SSA-based IR compiled to native code via Cranelift/LLVM
  • Link-Time Optimization — ThinLTO and Full LTO for maximum performance
  • Standalone Binaries — Self-contained executables with runtime stubs in LLVM IR
  • Memory Safety — Ownership model with compile-time borrow checking
  • Self-Hosting — Bootstrap compiler written in Oite itself
  • Type Inference — Flow-sensitive type analysis for optimization
  • JavaScript Syntax — Familiar syntax with ES6+ features
  • Classes & Inheritance — ES6 classes with extends, super(), and private fields
  • Error Handling — try/catch/finally with exception propagation

Architecture

Oite Core is like C without libc — a minimal, self-contained language that runs without dependencies. Everything else is optional.

┌─────────────────────────────────────────────────────────────────────────┐
│                           User App Code                                 │
└───────────────────────────────────┬─────────────────────────────────────┘
                                    │
                    ┌───────────────┴───────────────┐
                    │                               │
                    ▼                               ▼
┌───────────────────────────────────┐  ┌──────────────────────────────────┐
│         OITE CORE                 │  │            ROLLS                 │
│  ✅ Always available              │  │  ⚡ Optional system libraries     │
│                                   │  │                                  │
│  • Compiler (oitec)               │  │  • @rolls/http   HTTP server     │
│  • Runtime (NaN-boxing, heap)     │  │  • @rolls/tls    TLS encryption  │
│  • Primitives (number, string...) │  │  • @rolls/fs     File system     │
│  • console.log                    │  │  • @rolls/db     Databases       │
│                                   │  │  • @rolls/async  Event loop      │
│  Like C without libc:             │  │                                  │
│  Can run, can't do HTTP           │  │  Batteries for real apps         │
└───────────────────────────────────┘  └──────────────────────────────────┘
                    │                               │
                    └───────────────┬───────────────┘
                                    │
                                    ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                             UNROLL                                      │
│  Build system & package manager                                         │
│                                                                         │
│  • Resolves dependencies (Rolls + NPM → .nroll)                         │
│  • Produces single static binary                                        │
│  • Lockfile for reproducible builds                                     │
└───────────────────────────────────┬─────────────────────────────────────┘
                                    │
                                    ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                        ./myapp (Single Binary)                          │
│  ✅ No runtime required  ✅ No node_modules  ✅ Deploy: copy one file   │
└─────────────────────────────────────────────────────────────────────────┘

See Platform architecture for how core, Rolls and Unroll fit together.

Compilation Pipeline

┌─────────────────────────────────────────────────────────────────┐
│                         Oite Source                             │
└───────────────────────────┬─────────────────────────────────────┘
                            ▼
┌─────────────────────────────────────────────────────────────────┐
│                     Oite Compiler                               │
│  ┌─────────────┐  ┌──────────────┐  ┌────────────────────────┐  │
│  │   Parser    │─▶│ Borrow Check │─▶│   SSA IR Generation    │  │
│  │  (SWC AST)  │  │  (Ownership) │  │ (Type Inference, Opts) │  │
│  └─────────────┘  └──────────────┘  └────────────────────────┘  │
└───────────────────────────┬─────────────────────────────────────┘
                            ▼
┌─────────────────────────────────────────────────────────────────┐
│                    Native Backend                               │
│  ┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐  │
│  │  Cranelift JIT  │  │   LLVM AOT      │  │   VM (Debug)    │  │
│  │   (Fast)        │  │  (LTO, Native)  │  │  (Interpreter)  │  │
│  └─────────────────┘  └─────────────────┘  └─────────────────┘  │
└───────────────────────────┬─────────────────────────────────────┘
                            ▼
                          CPU

Quick Start

Prerequisites

Oite builds on macOS and Linux. Native Windows is not supported yet — use WSL2.

LLVM 18 is required to build Oite at all. llvm-sys is a mandatory dependency, so LLVM 18 and its development libraries must be installed even if you only intend to use the Cranelift JIT backend. cargo build fails without them.

macOS:

# Install LLVM 18 and zstd (required for linking)
brew install llvm@18 zstd

# Set LLVM environment variable (add to ~/.zshrc or ~/.bashrc for persistence)
export LLVM_SYS_180_PREFIX=$(brew --prefix llvm@18)

Linux (Ubuntu 24.04 / Debian 13+):

# Install LLVM 18 development headers, Polly, and zstd
sudo apt update
sudo apt install -y llvm-18-dev libpolly-18-dev libzstd-dev

# Set LLVM environment variable (add to ~/.bashrc for persistence)
export LLVM_SYS_180_PREFIX=/usr/lib/llvm-18

If your distribution has no llvm-18-dev package (e.g. Debian 12 "bookworm"), install LLVM 18 from apt.llvm.org. Prefer its llvm-18-dev package over the llvm.sh script — on distros that already ship LLVM 18, llvm.sh upgrades libllvm18 to a snapshot build that conflicts with llvm-18-dev.

Windows (WSL2):

Oite cannot currently be built natively on Windows, for two reasons:

  1. llvm-sys requires llvm-config, which the official LLVM Windows installer and the winget package do not ship (nor the static libs and headers it reports). Adding C:\Program Files\LLVM\bin to PATH therefore cannot work — the needed files are not there. Those installers also track the newest LLVM, while Oite needs 18.x.
  2. Oite's async reactor imports std::os::unix::io::RawFd unconditionally, which does not exist on Windows targets.

Use WSL2 and follow the Linux instructions inside it:

# In PowerShell (as Administrator)
wsl --install -d Ubuntu-24.04

Keep the repo in the Linux filesystem (e.g. ~/oite), not under /mnt/c/, for much faster builds.

Building

# Build
cargo build --release

# Run an Oite program
./target/release/oitec myprogram.ot

# Dump SSA IR (for debugging)
./target/release/oitec ir myprogram.ot

# Run with VM (debug mode)
./target/release/oitec --run-binary output.otb

# Build to native binary (requires LLVM)
./target/release/oitec build myprogram.ot --release -o myprogram

# Run the compiled binary
./myprogram

Language Features

Variables & Types

let x = 42; // Number
let name = "Oite"; // String
let active = true; // Boolean
let data = { key: 1 }; // Object
let items = [1, 2, 3]; // Array

Functions & Closures

// Function declaration
function greet(name) {
  return "Hello, " + name + "!";
}

// Arrow functions
let double = (x) => x * 2;
let add = (a, b) => a + b;

// Closures
function counter() {
  let count = 0;
  return () => {
    count = count + 1;
    return count;
  };
}

Control Flow

if (condition) {
  // ...
} else {
  // ...
}

for (let i = 0; i < 10; i++) {
  // ...
  if (done) break;
  if (skip) continue;
}

while (condition) {
  // ...
}

do {
  // ...
} while (condition);

Objects & Arrays

let obj = { x: 10, y: 20 };
obj.z = 30;
console.log(obj["x"]);

let arr = [1, 2, 3];
arr.push(4);
let first = arr[0];

Classes & Inheritance

class Animal {
    name: string;

    constructor(name: string) {
        this.name = name;
    }

    speak() {
        console.log(this.name + " makes a sound");
    }
}

class Dog extends Animal {
    breed: string;

    constructor(name: string, breed: string) {
        super(name);
        this.breed = breed;
    }

    speak() {
        console.log(this.name + " barks!");
    }
}

let dog = new Dog("Buddy", "Golden Retriever");
dog.speak();  // "Buddy barks!"

Private Fields

Oite supports JavaScript-style private fields using the # prefix:

class Counter {
  #count = 0; // Private field (only accessible within class)

  increment() {
    this.#count++;
  }

  getCount() {
    return this.#count; // Can access private field from methods
  }
}

let c = new Counter();
c.increment();
console.log(c.getCount()); // 1

// c.#count;       // ERROR: Private field not accessible outside class
// c["#count"];    // Returns undefined (encapsulation works)

Error Handling

try {
  riskyOperation();
} catch (e) {
  console.log("Error: " + e);
} finally {
  cleanup();
}

class HttpError extends Error {
  constructor(status, message) {
    super(message);
    this.status = status;
  }
}

Runtime errors are exceptions too: null.x throws a TypeError, an unbound name a ReferenceError. An uncaught one prints Uncaught TypeError: ... and exits with status 1.

Memory Model

At run time, assigning an object shares it, as in JavaScript. Nothing is copied, and memory is not freed yet (#123).

A compile-time move check rejects a use of a variable after its value was assigned to another variable:

let a = { value: 42 };
let b = a; // the value moves from 'a' to 'b'
// console.log(a.value);  // borrow error: Cannot borrow moved variable 'a'
console.log(b.value); // 42

let x = 10;
let y = x; // 'x' was initialized with a number literal, so it is copied
console.log(x); // 10

The check covers top-level code only, not function bodies. A string, the result of a call and an arithmetic result all move. .js files follow the same rules as .ot files. See Memory model for the full rules.

SSA IR

Oite compiles to an SSA (Static Single Assignment) intermediate representation:

// Source: let x = 1 + 2; let y = x * 3;

fn main() -> any {
bb0:
    v0 = const 1
    v1 = const 2
    v2 = add.num v0, v1      // Specialized to numeric add
    store.local $0, v2
    v3 = load.local $0
    v4 = const 3
    v5 = mul.any v3, v4
    return
}

// After optimization:
bb0:
    v2 = const 3             // 1+2 constant-folded!
    store.local $0, v2
    ...

Type Specialization

The type inference pass specializes dynamic operations:

Before After Speedup
add.any v0, v1 add.num v0, v1 ~10x
mul.any v0, v1 mul.num v0, v1 ~10x

Minimal Standard Library

Oite core provides only essential primitives:

Console

console.log("Hello", 42, true);
console.error("Error message");

ByteStream (Binary Data)

Used by the bootstrap compiler for bytecode emission. VM only:

let stream = ByteStream.create();
ByteStream.writeU8(stream, 0xff);
ByteStream.writeU32(stream, 12345);
ByteStream.writeF64(stream, 3.14159);
ByteStream.writeString(stream, "hello");
let bytes = ByteStream.toArray(stream);

File I/O (Minimal)

Basic file operations for the bootstrap compiler. VM only: oitec jit and oitec build refuse require.

let fs = require("fs");
let content = fs.readFileSync("file.txt");
fs.writeFileSync("out.txt", "Hello!");

Note: Full standard library functionality (Math, Date, JSON, comprehensive fs/path, etc.) will be provided by the Rolls ecosystem in a separate repository. See Platform architecture for the plan.

Project Structure

Oite/
├── Cargo.toml                    # Minimal dependencies
├── README.md                     # This file
├── PROGRESS.md                   # Development status
├── compiler/                     # Self-hosted compiler (modular, target)
│   ├── main.ot                 # CLI entry point
│   ├── lexer/                    # Tokenization module
│   ├── parser/                   # AST generation module
│   ├── ast/                      # AST type definitions
│   ├── ir/                       # IR system module
│   ├── codegen/                  # Code generation module
│   └── stdlib/                   # Runtime declarations
├── bootstrap/                    # Bootstrap compiler (working reference)
│   └── *.ot                    # 11 files (~5,000 lines)
├── src/
│   ├── main.rs                   # Entry point
│   ├── lib.rs                    # Library target
│   ├── compiler/                 # Rust compiler (production)
│   │   ├── mod.rs                # Parser → Bytecode
│   │   └── borrow_ck.rs          # Borrow checker
│   ├── ir/
│   │   ├── mod.rs                # SSA IR types
│   │   ├── lower/                # Bytecode → IR
│   │   ├── typecheck.rs          # Type inference
│   │   ├── verify.rs             # Validation
│   │   ├── opt.rs                # Optimizations
│   │   └── format.rs             # IR serialization
│   ├── backend/
│   │   ├── mod.rs                # Backend trait
│   │   ├── cranelift/            # JIT backend
│   │   ├── jit.rs                # JIT runtime
│   │   ├── layout.rs             # Memory layout
│   │   └── llvm/                 # AOT backend
│   ├── types/                    # Type checker
│   ├── runtime/
│   │   ├── mod.rs                # Runtime module
│   │   ├── abi.rs                # NaN-boxed values
│   │   ├── heap.rs               # Memory allocation
│   │   ├── stubs/                # The native runtime
│   │   └── async/
│   │       ├── mod.rs            # Core async traits
│   │       ├── task.rs           # Task abstraction
│   │       ├── reactor.rs        # Basic epoll/kqueue
│   │       └── runtime_impl.rs   # Simple executor
│   ├── vm/                       # Debug interpreter
│   │   ├── mod.rs                # VM implementation
│   │   ├── value.rs              # Runtime values
│   │   ├── opcodes.rs            # Bytecode opcodes
│   │   └── stdlib_setup.rs       # Minimal setup
│   └── stdlib/
│       └── mod.rs                # console, ByteStream only
├── docs/                         # Documentation site
│   ├── docs/                     # Language, status, platform architecture
│   ├── docs-compiler/            # Compiler internals, self-hosting
│   ├── docs-rolls/               # Rolls (system libraries)
│   └── docs-unroll/              # Unroll (tooling)
└── tests/

Compiler Architecture

Oite has three compiler implementations working toward full self-hosting:

Compiler Location Status Purpose
Rust src/compiler/ ✅ Production Native binaries via LLVM/Cranelift
Bootstrap bootstrap/*.ot 🟡 Reference, runs on the VM Bytecode compiler written in Oite; seed for self-hosting
Modular compiler/*.ot 🟡 Partial, runs on the VM LLVM IR for simple programs; cannot compile its own source yet

Self-Hosting Status

Self-hosting is partial. The modular compiler runs on the VM and turns simple programs into LLVM IR, but it cannot compile its own source yet (#131), and scripts/bootstrap_verify.sh checks that one module compiles deterministically, not a full self-compilation fixpoint.

# Generate LLVM IR with the self-hosted compiler (runs on the VM).
# Run it from the repository root; it writes myapp.ll next to myapp.ot.
./target/release/oitec compiler/main.ot llvm myapp.ot

# Compile to native binary (-lm: the generated code calls fmod)
clang myapp.ll -lm -o myapp
./myapp

Current requirements:

  • Rust: Still needed to build the VM that runs the self-hosted compiler
  • LLVM/Clang: Required to compile generated LLVM IR to native code

Roadmap to full independence:

Current:    Rust VM runs compiler/*.ot → LLVM IR → clang → Native
Future:     Prebuilt oitec binary → LLVM IR → clang → Native (no Rust!)

See Self-hosting for the detailed roadmap.

Development Status

Pre-alpha. Development Status has the per-feature matrix for each backend; a feature counts as done there only when golden tests in tests/lang/ cover it.

Component Status
Runtime kernel (NaN-boxing, allocator) 🟡 Works; memory is never freed (#123)
SSA IR + optimizations ✅ Works
Native backends (Cranelift JIT, LLVM AOT) ✅ Same language features as the VM; some globals are VM-only (see above)
Language features (classes, async, modules) 🟡 On every backend; no generators, regular expressions or tagged templates yet
Static type checking 🟡 Warnings; oitec check reports errors; generic calls are not checked (#190)
Self-hosting compiler 🟡 Cannot compile its own source yet (#131)
Rolls ecosystem (HTTP, TLS, fs) 📋 Planned; needs an FFI first (#132)

See PROGRESS.md for design notes.

Testing

# Run all tests
cargo test --release

# Run specific IR tests
cargo test --release ir::

Future: Rolls & Unroll

The Oite ecosystem will eventually include:

  • Rolls: Official system libraries (@rolls/http, @rolls/tls, @rolls/fs, etc.)
  • Unroll: Package manager, build system, and developer tooling

See Platform architecture and the Unroll design.

Contributing

Contributions are welcome! CONTRIBUTING.md has the rules a change must follow.

License

Oite is distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.

About

Unroll a new functional programming language

Resources

Code of conduct

Contributing

Stars

81 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages