METOREX (Meta Object Runtime Execution) is a programming language that combines the expressiveness of Ruby with the performance and safety of Rust. It features a unique Code-as-Object meta-programming system that exposes the AST as first-class runtime objects, enabling powerful DSL construction and runtime code manipulation.
🙂 PRs and new issues are welcome.
METOREX is currently in active development following a 4-phase roadmap:
- Phase 1 (MVP): AST Interpreter with meta-programming core - In Progress
- Phase 2: Bytecode VM with reflection maturity - Planned
- Phase 3: Optimization, concurrency, and production features - Planned
- Phase 4: Advanced features (macros, WebAssembly, functional programming) - Planned
See ROADMAP.md for detailed implementation plans.
- Exception Handling: Full begin/rescue/ensure with exception hierarchies and stack traces
- Pattern Matching: Powerful pattern matching with destructuring and guards
- Built-in Testing: Integrated test framework with assertions and test discovery
- Traits/Interfaces: Flexible polymorphism through trait system
- Optional Type System: Gradual typing with type inference for performance and safety
- Advanced Collections: Set, Deque, PriorityQueue, TreeMap, and immutable structures
- Runtime Class System: Classes support inheritance, runtime method definition, instance variables, and class-level state
- Code-as-Object: AST nodes are first-class objects manipulable at runtime
- Runtime Method Definition:
define_methodfor dynamic behavior - AST Reflection: Inspect and modify code structure at runtime
- Block Execution: Blocks are objects with
.call()method - DSL Construction: Build domain-specific languages naturally
- Networking: HTTP client/server, WebSocket, TCP/UDP, TLS/SSL
- Serialization: JSON, XML, YAML, CSV, MessagePack
- Cryptography: Hashing, encryption, secure random, certificates
- Concurrency: OS threads, fibers, async/await, channels, atomics
- Advanced Math: Complex numbers, arbitrary precision, statistics
- Documentation System: Doc comments with automatic HTML generation
- Debugger: Full debugging with breakpoints and inspection
- LSP Support: Language Server Protocol for IDE integration
- Build System: Incremental compilation, profiles, and optimization
- Linter & Formatter: Code quality and style enforcement
| Element | Description |
|---|---|
| Foundation Language | Rust (for VM safety and speed) |
| Syntax Heritage | Ruby (block structure, optional parentheses) |
| Primary Paradigms | Full Object-Oriented, Imperative, Functional (with ADTs and immutable structures) |
| Key Differentiator | Code-as-Object (The Meta Core): The Abstract Syntax Tree (AST) is directly exposed as native, manipulable objects at runtime. |
| Typing | Dynamic by default, with optional static typing and gradual type inference |
| Performance | Bytecode VM with JIT compilation for hot paths, built on Rust for safety |
METOREX syntax prioritizes readability while minimizing keystrokes, combining elements from Ruby.
See examples/exception_handling.mx
See examples/pattern_matching.mx
See examples/type_annotations.mx
METOREX exposes the program's structure as native objects, eliminating the need for external eval functions.
The parser converts source code into an in-memory graph of objects, defined in the Rust core and exposed in Metorex.
| Metorex Class Name | Role | Example of Manipulation |
|---|---|---|
BlockStatement |
The Core Meta-Object. Represents a sequence of code lines (a method body, loop body, or implicit code block). | block.call to execute the code. |
Assignment |
Represents x = 10. |
.target to see the variable name. |
MethodCall |
Represents a function/method invocation. | .receiver and .args for code analysis. |
Methods can accept code blocks as objects.
See examples/metaprogramming/blocks_as_objects.mx
See examples/dynamic_method_definition.mx
- Phase 1 (MVP): Direct AST interpretation for rapid development
- Lexer → Parser → AST → Interpreter
- Full meta-programming capabilities
- Exception handling, pattern matching, testing
VirtualMachine(src/vm.rs) seeds the AST interpreter with the environment stack, global object registry, call stack, heap placeholder, and built-in class initialization.
-
Phase 2: Bytecode compilation for performance
- AST → Bytecode Compiler → VM
- Reflection and runtime definition
- Traits and advanced OOP
-
Phase 3: Production optimizations
- JIT compilation for hot paths (LLVM)
- Full concurrency support (threads, channels, atomics)
- Optional type system with inference
- Comprehensive standard library
-
Phase 4: Advanced features
- Macro system for compile-time metaprogramming
- Algebraic data types and functional features
- WebAssembly compilation target
- Security features and sandboxing
| Principle | Implementation |
|---|---|
| Syntax Simplicity | Non-whitespace sensitive with mandatory end blocks. No colons, optional parentheses. |
| OO Purity | Everything is an object rooted in Object class. No standalone functions. |
| Meta-First | AST is always accessible as first-class objects. Code can inspect and modify itself. |
| Gradual Typing | Dynamic by default, optional static types for performance. Best of both worlds. |
| Performance | Rust-based VM with bytecode compilation and JIT for hot paths. |
| Safety | Exception handling, memory safety from Rust, optional sandboxing. |
| Concurrency | Multiple models: fibers, async/await, OS threads, channels. Choose the right tool. |
| Productivity | Built-in testing, documentation, linting, formatting. Everything you need included. |
See ROADMAP.md for complete details.
- Lexer and Parser
- AST Interpreter
- Expression evaluation (arithmetic, collections, indexing)
- Method dispatch for built-in objects
- Meta-programming core
- Exception handling
- Pattern matching
- Built-in testing framework
- Bytecode compiler
- Stack-based VM
- Trait/interface system
- Advanced reflection
- JIT compilation (LLVM)
- Full concurrency (threads, channels, atomics)
- Networking library (HTTP, WebSocket, TCP/UDP)
- Cryptography library
- Optional type system
- Documentation generator
- LSP support
- Macro system
- Algebraic data types (Option, Result)
- Functional programming features
- WebAssembly compilation
- Security and sandboxing
- Advanced tooling (profilers, static analysis)
METOREX is in active development. We welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone the repository
git clone https://github.com/yourusername/metorex.git
cd metorex
# Build the project
cargo build
# Run tests
cargo test
# Run the REPL
cargo runSee LICENSE for details.
For DSL Creators: Build domain-specific languages naturally with first-class AST access.
For Scripters: Ruby-like syntax with powerful built-in libraries.
For Systems Programmers: Rust-based VM with performance and safety guarantees.
For Functional Enthusiasts: Optional algebraic data types, immutable structures, and functional patterns.
For Pragmatists: One language that adapts to your needs - from quick scripts to production systems.
METOREX: Where meta-programming meets production-ready performance.