Skip to content

oxchin/iozen-lang

 
 

Repository files navigation

Safe, expressive systems programming with natural language syntax

License: MIT Version Bootstrap: TypeScript Phase

IOZEN reads like English, compiles like Rust.


What is IOZEN?

IOZEN is a systems programming language that combines Rust-like memory safety (ownership & borrowing) with natural language syntax. It provides compile-time memory guarantees without lifetime annotations, using readable keywords that make code self-documenting and accessible to a wider audience of developers.

The vision: a language as safe as Rust, but as readable as Python. A language where create variable x as integer with value 42 replaces let x: i32 = 42; — not because symbols are bad, but because clarity should be the default.

Key Principles

  • Memory safety without the pain — ownership and borrowing enforced at compile time, no garbage collector, no lifetime annotations
  • Natural language first — code that reads like prose; when x is greater than 5 do instead of if x > 5 {
  • Zero-cost abstractions — high-level constructs compile down to efficient machine code
  • Self-hosting goal — IOZEN's compiler will eventually be written in IOZEN itself

Quick Start

Prerequisites

Install

# Clone the repository
git clone https://github.com/iozen-lang/iozen.git
cd iozen

# Install dependencies
npm install

Hello World

Create a file called hello.iozen:

print "Hello, World!"

Run

# Using Bun (recommended)
bun run iozen-cli/src/cli.ts run hello.iozen

# Using npx
npx iozen run hello.iozen

Create a New Project

bun run iozen-cli/src/cli.ts init my_project
cd my_project
bun run ../iozen-cli/src/cli.ts run main.iozen

Build Standalone Binary

bun run iozen-cli/src/cli.ts build main.iozen --output my_program
./my_program

Code Examples

Variables & Types

create variable name as text with value "IOZEN"
create variable version as integer with value 1
create variable pi as float with value 3.14159
create variable active as boolean with value true

print "Language: " attach name attach ", Version: " attach version

Functions

function greet with name as text returns text
    return "Hello, " attach name attach "!"
end

function factorial with n as integer returns integer
    when n is less than or equal to 1 do
        return 1
    end
    return n * factorial with n - 1
end

print greet with "World"
print "5! = " attach factorial with 5

Control Flow

create variable score as integer with value 85

when score is greater than or equal to 90 do
    print "Grade: A"
otherwise when score is greater than or equal to 80 do
    print "Grade: B"
otherwise when score is greater than or equal to 70 do
    print "Grade: C"
otherwise do
    print "Grade: F"
end

Loops

# Repeat loop
repeat 5 times
    print "IOZEN is awesome!"
end

# While loop
create variable i as integer with value 0
while i is less than 5 do
    print "Count: " attach i
    increase i by 1
end

# For each loop
create variable fruits as list with value ["apple", "banana", "cherry"]
for each fruit in fruits do
    print "I like " attach fruit
end

Structures

structure Point
    field x as integer
    field y as integer
end

create variable origin as Point with x = 0 and y = 0
create variable target as Point with x = 3 and y = 4
print "Origin: (" attach origin.x attach ", " attach origin.y attach ")"

Lists

create variable numbers as list with value [10, 20, 30, 40, 50]
print "Count: " attach length(numbers)
print "Sum: " attach sum(numbers)
print "Sorted: " attach sort(numbers)

push(numbers, 60)
print "After push: " attach numbers

Error Handling with Result Type

function safe_divide with a as integer and b as integer returns integer
    when b equals 0 do
        return 0
    end
    return a / b
end

create variable result as integer with value safe_divide with 10 and 3
print "10 / 3 = " attach result

FizzBuzz — The Classic

function fizzbuzz with n as integer returns nothing
    create variable i as integer with value 1
    while i is less than or equal to n do
        create variable mod3 as integer with value i % 3
        create variable mod5 as integer with value i % 5

        when mod3 equals 0 and mod5 equals 0 do
            print i attach " → FizzBuzz"
        otherwise when mod3 equals 0 do
            print i attach " → Fizz"
        otherwise when mod5 equals 0 do
            print i attach " → Buzz"
        otherwise do
            print i attach " → " attach i
        end

        increase i by 1
    end
end

fizzbuzz with 30

Features

Feature Description
Natural Language Syntax Keywords like create variable, when, otherwise, repeat, function make code self-documenting
Memory Safety Ownership and borrowing system inspired by Rust — no data races, no use-after-free
No Lifetime Annotations Ownership rules enforced without explicit 'a lifetime parameters
Strong Static Typing integer, float, boolean, text, character, list, pointer, address
Pattern Matching Powerful when/otherwise/check branching for expressive control flow
Error Handling Built-in Result type for explicit, safe error propagation
Algebraic Data Types structure, enum, union for modeling complex domains
Generics Type parameters for reusable, type-safe abstractions
Concurrency task, send, receive, parallel for safe concurrent programming
FFI declare external to call C functions directly
Self-Hosting Path Bootstrap compiler in TypeScript; self-hosting lexer already working

Language Comparison

Aspect IOZEN Rust C++
Readability ★★★★★ ★★★☆☆ ★★☆☆☆
Memory Safety ★★★★★ ★★★★★ ★★☆☆☆
No Lifetime Annotations N/A
Learning Curve Low Steep Steep
Ownership System
Borrow Checker
Natural Language Syntax
Type Inference Partial
Pattern Matching C++23
Error Propagation Result type Result/Option Exceptions
Self-Hosting In progress
Garbage Collector
FFI (C interop) Native

Bootstrap Roadmap

IOZEN follows the classic bootstrapping path pioneered by languages like Rust (OCaml → Rust). TypeScript serves as the temporary bootstrap language — once IOZEN can compile itself, TypeScript will no longer be needed.

  • Phase 0 — TypeScript bootstrap compiler (lexer, parser, tree-walking interpreter, CLI)
  • Phase 1 — Self-hosting lexer written in IOZEN (bootstrap/lexer.iozen)
  • Phase 2 — Self-hosting parser written in IOZEN (bootstrap/parser.iozen)
  • Phase 3 — Self-hosting interpreter/codegen written in IOZEN
  • Phase 4 — Full self-hosting: IOZEN compiles IOZEN
TypeScript ──→ IOZEN Lexer ──→ IOZEN Parser ──→ IOZEN Compiler ──→ IOZEN
  (Phase 0)      (Phase 1)       (Phase 2)       (Phase 3)      (Phase 4)
     ✅              ✅              ✅              ⏳            ⏳

The bootstrap language doesn't determine the final language. Rust was bootstrapped from OCaml, Go from C, Zig from C++. Once self-hosting is achieved, the bootstrap language is discarded entirely.

CLI Commands

# Run an IOZEN program
iozen run <file.iozen>

# Compile to standalone binary (requires Bun)
iozen build <file.iozen> [--output <name>]

# Create a new IOZEN project
iozen init <project-name>

# Inspect tokens (debugging)
iozen tokens <file.iozen>

# Inspect AST (debugging)
iozen ast <file.iozen>

# Show version
iozen version

CLI vs Cargo Comparison

IOZEN Rust Description
iozen init myproject cargo new myproject Create new project
iozen run main.iozen cargo run Run project
iozen build main.iozen cargo build --release Build binary
iozen tokens main.iozen Inspect tokens
iozen ast main.iozen Inspect AST

Built-in Functions

Math

abs, sqrt, floor, ceil, round, power, min, max

String

length, uppercase, lowercase, trim, substring, contains, replace, split, char_at, ord, chr

List

push, pop, sort, reverse, join, range, sum, length

Type Conversion

to_integer, to_float, to_text

Project Structure

iozen/
├── bootstrap/
│   └── lexer.iozen              # Self-hosting lexer written in IOZEN (Phase 1)
├── iozen-cli/
│   ├── src/
│   │   └── cli.ts              # CLI entry point
│   └── examples/
│       ├── hello.iozen          # Hello World
│       ├── fibonacci.iozen      # Fibonacci sequence
│       ├── fizzbuzz.iozen       # FizzBuzz challenge
│       └── prime.iozen          # Prime number sieve
├── src/lib/iozen/
│   ├── index.ts                # Module exports
│   ├── tokens.ts               # Token type definitions (60+ tokens)
│   ├── lexer.ts                # Lexical analyzer / tokenizer
│   ├── ast.ts                  # AST node types (30+ nodes)
│   ├── parser.ts               # Recursive descent parser
│   ├── interpreter.ts          # Tree-walking interpreter (40+ built-ins)
│   └── environment.ts          # Lexical scoping & runtime environment
├── .github/
│   ├── ISSUE_TEMPLATE/
│   │   ├── bug_report.md
│   │   └── feature_request.md
│   └── PULL_REQUEST_TEMPLATE.md
├── CONTRIBUTING.md
├── LICENSE                     # MIT
├── README.md
├── package.json
└── tsconfig.json

Contributing

We welcome contributions of all kinds — bug fixes, new features, documentation improvements, or even just ideas. Please read our Contributing Guide to get started.

License

IOZEN is released under the MIT License.


Built with ❤ by the IOZEN community

IOZEN reads like English, compiles like Rust.

About

Safe, expressive systems programming with natural language syntax. Reads like English, compiles like Rust.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 100.0%