Ruchy
A functional programming language that transpiles to idiomatic Rust, featuring a production-grade REPL with complexity-optimized interpreter and comprehensive test coverage.
šÆ Quick Start
# Install from crates.io
# Run a one-liner
# Run with JSON output
# Start the REPL
# Run a script
⨠Key Features
Production-Grade REPL
- Resource-bounded evaluation: Memory limits, timeouts, stack depth protection
- Multiline editing: Automatic detection of incomplete expressions
- Syntax highlighting: Real-time colored output with O(n) performance
- Tab completion: Context-aware completions with O(1) keyword lookups
- Persistent history: Cross-session command history
Core Language Features
// Pattern matching with exhaustiveness checking
match value {
0 => "zero",
1..=10 => "small",
_ => "large"
}
// String interpolation
let name = "Ruchy"
println(f"Hello from {name}!")
// Functional programming
[1, 2, 3, 4, 5]
.map(|x| x * 2)
.filter(|x| x > 5)
.reduce(0, |acc, x| acc + x)
// Loop expressions
for i in 1..=5 {
println(i)
}
// Block expressions return values
let result = {
let a = 10
let b = 20
a + b // Returns 30
}
Type System
- Type inference with bidirectional checking
- Option and Result<T, E> types
- Generic functions and structs
- Trait definitions and implementations
šļø Architecture
For Rust Developers
The Ruchy interpreter showcases advanced Rust patterns and optimizations. Read the detailed Interpreter Architecture to learn about:
- Resource-bounded evaluation with
Instantdeadlines and memory tracking - Zero-allocation patterns using
&strand arena allocators - O(1) HashSet lookups replacing O(n²) algorithms
- Modular complexity management keeping all functions under 50 cyclomatic complexity
- Property-based testing with
proptestfor invariant verification - Fuzz testing for crash resistance
Interpreter (v0.8.0 - Complexity Optimized)
- Cyclomatic complexity: Reduced from 209 to 50 (76% reduction)
- Display formatting: Extracted to modular helpers (<30 complexity each)
- O(n²) algorithms eliminated: HashSet-based lookups for O(1) performance
- Memory tracking: Per-evaluation resource bounds with
AtomicUsize
Transpiler
- Direct Rust code generation via
quote!macros - Zero-cost abstractions with
synandproc-macro2 - Hygienic macro expansion
- Incremental compilation support
š Quality Metrics
Tests: 271 passing (library)
34 passing (interpreter core)
10 property tests
10 fuzz tests
33 doctests
Code Coverage: >80%
Complexity: All functions <50 (enforced by PMAT)
Performance: 50MB/s parsing throughput
š§ Development
# Run tests
# Check quality gates
# Run benchmarks
# Generate documentation
Quality Gates (Toyota Way - Zero Defects)
All commits must pass:
- Core interpreter reliability tests
- REPL functionality tests
- Cyclomatic complexity <50
- Zero clippy warnings
- 80% test coverage minimum
See CLAUDE.md for the full development protocol.
š Documentation
- Interpreter Architecture - Deep dive into the v0.8.0 complexity-optimized interpreter
- Language Specification - Complete language reference
- Roadmap - Development progress and priorities
- Contributing Guidelines - How to contribute
š Current Focus (v0.8.0)
- ā Interpreter complexity reduction (209 ā 50)
- ā O(n²) algorithm elimination
- ā Display formatting modularization
- ā Extended test coverage (property, fuzz, examples)
- š Binary compilation via LLVM
- š DataFrame operations
- š Actor system
š¦ Installation
From crates.io
From source
š¤ Contributing
Contributions welcome! Please read CONTRIBUTING.md first.
Key principles:
- Zero defects (Toyota Way)
- Complexity budget (<50 per function)
- Test coverage >80%
- All PRs must pass quality gates
š License
MIT - See LICENSE for details.
Made with š¦ in Rust | Documentation | Crates.io