Skip to content

J-x-Z/AetherLang

Repository files navigation

AetherLang

AI-Native Systems Programming Language - Designed to reduce AI hallucinations and enable AI self-iteration

License Tests Self-Hosting

🎯 Vision

AetherLang is an AI-Native Programming Language built from the ground up to:

  1. Reduce AI Hallucinations - Explicit interfaces, constrained syntax, semantic annotations
  2. Enable AI Self-Iteration - AI-readable IR, structured feedback, sandboxed optimization
  3. Maintain Rigor & Safety - Contract programming, effect system, ownership semantics

πŸ”„ Self-Hosting Progress

πŸŽ‰ Self-hosting complete! AetherLang compiler is written in AetherLang.

Component Status Functions Notes
Lexer βœ… 100% 23 Tokenization with 80+ token types
Parser βœ… 100% 76 Full AST generation
Semantic Analyzer βœ… 100% 68 Type checking, ownership analysis
IR Generator βœ… 100% 52 Three-address code generation
Codegen βœ… 100% 40 Native object file output
Total βœ… 259 All modules compile to native code

✨ Key Features (P1 Complete)

Language Features

  • Type System: i8-i64, u8-u64, f32, f64, bool, char, *T, &T, &mut T
  • Generics: Type erasure with Vec<T>, Option<T> style syntax
  • Traits: trait Display { fn display(&self); }
  • Lifetimes: &'a T, &'static T annotations
  • Type Aliases: type Int = i64;
  • Closures: |x, y| x + y lambda syntax

Module System

  • Use Imports: use module::{Item1, Item2}
  • Dynamic Loading: Auto-search in ., src_aether/, stdlib/
  • Public Exports: pub struct, pub fn

System Features

  • FFI: extern "C" { fn puts(s: *u8) -> i32; }
  • Unions: Memory-overlapping types
  • Volatile: *volatile T for memory-mapped I/O
  • Inline ASM: asm!("mov eax, 1") (planned)

✨ Dual-Layer Architecture

AetherLang introduces a novel Dual-Layer Architecture to balance high-level productivity with system-level control.

Layer 1: Aether Script (.ath)

The high-level logic layer. Used for rapid development, scripting, and business logic.

  • Indentation-based syntax for readability
  • Mutable-by-default to align with algorithmic pseudocode
  • Implicit Context management (Anti-Leak System)
  • Transpiles directly to Layer 0 (Aether Core)

Layer 0: Aether Core (.aeth)

The low-level system layer. Used for kernel, drivers, and performance-critical paths.

  • Explicit Ownership & Lifetimes
  • Effect System (pure, effect[io]) tracking side-effects
  • Contract Programming (requires/ensures) for formal verification

πŸ—οΈ Technical Stack

src/
β”œβ”€β”€ frontend/     # Lexer, Parser, Semantic Analysis, Module System
β”‚   β”œβ”€β”€ lexer.rs      # 80+ tokens, unicode support
β”‚   β”œβ”€β”€ parser.rs     # Full expression/statement parsing
β”‚   β”œβ”€β”€ semantic.rs   # Type inference, ownership, traits
β”‚   └── module.rs     # ModuleLoader for use statements
β”œβ”€β”€ script/       # Aether Script Frontend & Transpiler (Layer 1)
β”œβ”€β”€ middle/       # IR Generation and Optimization
β”‚   β”œβ”€β”€ ir.rs         # Three-address code IR
β”‚   └── ir_gen.rs     # AST to IR translation
β”œβ”€β”€ backend/      # ELF Linker, C / LLVM Code Generation
β”‚   └── llvm/         # LLVM backend integration
β”œβ”€β”€ ai_ir/        # πŸ†• AI-Readable IR Layer
└── types/        # Type System & Resolution

πŸš€ Quick Start

# Build the compiler
cargo build --release --features llvm

# Compile and run a program
cargo run --features llvm -- build examples/hello.aeth
./hello

# Run all tests
cargo test

Example: Hello World

// hello.aeth
extern "C" {
    fn puts(s: *u8) -> i32;
}

fn main() -> i32 {
    puts("Hello, AetherLang!" as *u8);
    return 0;
}

Example: Generic Function

fn identity<T>(x: T) -> T {
    return x;
}

fn main() -> i32 {
    let a: i64 = identity(42);
    return a as i32;
}

Example: Module Import

// point.aeth
pub struct Point { x: i64, y: i64 }
pub fn create_point(x: i64, y: i64) -> Point { Point { x: x, y: y } }

// main.aeth
use point::{Point, create_point}
fn main() -> i32 { ... }

πŸ“Š Development Status

Phase Status Description
P0: Self-Hosting βœ… 5/5 modules, 259 functions compiled
P1: Core Language βœ… Floats, generics, closures, traits, lifetimes, modules
P2: Platforms βœ… Linux, macOS, Windows CI passing
P3: SIMD/Matrix βœ… Vector types f32x4, BLAS FFI, Matrix4x4
P4: Kernel Dev βœ… Inline ASM, naked functions, atomic, MMIO
P5: AI/GPU βœ… CUDA, Metal, Tensor, Autograd

πŸ“¦ JXZ Package Manager

AetherLang includes JXZ - a cross-platform package manager (like Homebrew/Cargo):

# Project management
jxz init          # Create new project
jxz build         # Build project
jxz run           # Build and run
jxz test          # Run tests

# Dependency management
jxz add <pkg>     # Add dependency
jxz install       # Install from Jxz.lock
jxz update        # Update dependencies

# System packages (Homebrew-style)
jxz install <pkg> # Install to ~/.jxz/Cellar
jxz search <q>    # Search registry
jxz list          # List installed
jxz doctor        # Check for issues

161 functions written entirely in AetherLang (self-hosting!)

πŸ“š Documentation

Language Reference

Design Documents

Tutorials

πŸ”¬ For AI Models

AetherLang is designed to be AI-friendly:

  1. Constrained Syntax - Fewer ways to express the same thing
  2. Explicit Semantics - Ownership, effects, contracts all visible
  3. Structured Errors - Machine-readable output with fix suggestions
  4. AI-IR Layer - Semantic graph + intent annotations for AI understanding

🀝 Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

License

Apache License 2.0 - see LICENSE

About

A self-hosting systems programming language for Aether OS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published