Skip to content

adityachauhan0/hyle

Repository files navigation

Hyle

Hyle is a high-performance, stack-based Virtual Machine and dynamic programming language implemented in Rust. It features a hand-written single-pass compiler, a Mark-and-Sweep Garbage Collector, and robust Object-Oriented capabilities.


🚀 Key Features

  • Fast & Lightweight: Stack-based bytecode execution model for efficient performance.
  • Memory Managed: Custom Mark-and-Sweep Garbage Collector handles memory automatically, detecting cycles and stress.
  • First-Class Functions: Full support for Closures, higher-order functions, and lexical scoping.
  • Object-Oriented: Classes, Instances, Inheritance (single), Methods, and this binding.
  • Robust Compilation: Single-pass Pratt Parser that compiles directly to bytecode.
  • Zero-Dependency: Written in pure Rust with standard libraries only.

🛠️ Installation & Usage

Prerequisites

  • Rust (latest stable)

Running a Script

Run Hyle scripts using cargo run. For best performance, always use the --release flag.

cargo run --release <script.hyle>

Example

// fib.hyle
fun fib(n) {
  if (n < 2) return n;
  return fib(n - 1) + fib(n - 2);
}

print fib(28);

For full language documentation, check out LANGUAGE.md.

📊 Benchmarks

Benchmarks were run on a standard Linux environment using release builds.

Benchmark Description Result
Fibonacci Recursive calculation of fib(28) ~1.04s
Zoo Creation of 10,000 objects + 60k field accesses ~0.21s

Note: These benchmarks measure pure VM execution overhead including method dispatch, stack manipulation, and garbage collection pressure.

🧠 Architecture

  • Compiler: Converts source code to Bytecode (Chunk) in a single pass.
  • Virtual Machine: Executes bytecode instructions in a tight loop.
  • Stack: Stores temporary values and call frames (ObjClosure).
  • Heap: Stores dynamically allocated objects (ObjString, ObjInstance, ObjClass) managed by the GC.

📄 License

This project is open source and available for educational and performance research purposes.

About

A high-performance, stack-based Virtual Machine and dynamic programming language implemented in Rust. Features a Mark-and-Sweep Garbage Collector, Single-Pass Compiler, and Object-Oriented capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages