ruchy 3.0.0

A systems scripting language that transpiles to idiomatic Rust with extreme quality engineering
Documentation

Ruchy - Self-Hosting Programming Language

License: MIT Rust 1.75+ Crates.io

Ruchy is a self-hosting programming language with comprehensive tooling and quality engineering practices based on Toyota Way principles.

Quick Start

# Install from crates.io
cargo install ruchy

# Run a one-liner
ruchy -e "println('Hello, World!')"

# Start the REPL
ruchy repl

# Run a script
ruchy run script.ruchy

# Check syntax
ruchy check script.ruchy

# Format code
ruchy fmt script.ruchy

# Lint code
ruchy lint script.ruchy

Current Status - v1.88.0 (September 2025)

🎯 Book Compatibility: 95.6%

  • 219 of 229 examples passing
  • 100% test coverage
  • 94.0/100 TDG quality score (A grade)
  • Path to 100%: Only 2 critical bugs remaining

🚀 Recent Achievements

  • Main function auto-execution implemented
  • Format string processing fixed ({:.2} now works)
  • Comprehensive error handling (try-catch-finally, throw, panic!)
  • Pattern matching with destructuring (arrays, tuples, objects)
  • PMAT v2.68.0+ quality enforcement integrated

📊 Quality Metrics

  • Code Quality: 94.0/100 TDG score across 361 files
  • Test Coverage: 49.90% overall, 81.2% transpiler
  • Zero Technical Debt: No TODO/FIXME/HACK comments
  • Pre-commit Gates: Automated quality enforcement

Key Features

Self-Hosting Capability

  • Bootstrap compiler written in Ruchy
  • Transpiles to Rust for compilation
  • Type inference with Algorithm W
  • Complete language features for compiler development

Language Features

  • Pipeline Operator: data |> transform |> filter
  • Pattern Matching: With guards: x if x > 0 => "positive"
  • Lambda Syntax: Both |x| x + 1 and x => x + 1
  • Module System: use, mod, and :: path resolution
  • Error Handling: Result/Option types with ? operator
  • Collections: HashMap, HashSet with standard methods
  • String/Array Methods: Comprehensive built-in methods

CLI Commands

Command Purpose
ruchy check Syntax validation
ruchy fmt Code formatting
ruchy lint Quality analysis
ruchy test Test execution
ruchy ast AST visualization
ruchy run Script execution
ruchy repl Interactive environment
ruchy transpile Convert to Rust
ruchy wasm 🚀 NEW: Compile to WebAssembly
ruchy notebook 📊 NEW: Start interactive data science notebook

🚀 WebAssembly Compilation

# Compile Ruchy to WebAssembly
ruchy wasm my_program.ruchy --output program.wasm --verbose

# Generate optimized WASM for different targets
ruchy wasm script.ruchy --target browser --optimize --validate
ruchy wasm api.ruchy --target nodejs --deploy aws-lambda

📊 Data Science Notebook

# Start interactive notebook server
ruchy notebook --port 8888

# Enable all data science features (default in v1.93.0+)
cargo install ruchy

# Minimal installation (just core language)
cargo install ruchy --no-default-features --features minimal

Batteries-Included Features (Default):

  • 📊 DataFrames: Polars integration for data manipulation
  • 🚀 WebAssembly: Direct compilation to WASM modules
  • 📝 Notebooks: Interactive Jupyter-like environment
  • 🧮 Math Libraries: Statistical operations and linear algebra

REPL Features

  • Tab completion with context awareness
  • Syntax highlighting
  • Persistent history across sessions
  • Multiline editing
  • Magic commands (:help, :load, :save)
  • Resource limits (memory, timeout, stack depth)

Example Code

// Function definition
fun parse_expr(tokens: Vec<Token>) -> Result<Expr, ParseError> {
    match tokens.first() {
        Some(Token::Number(n)) => Ok(Expr::Literal(*n)),
        Some(Token::Ident(name)) => Ok(Expr::Variable(name.clone())),
        _ => Err(ParseError::UnexpectedToken)
    }
}

// Pipeline operator
[1, 2, 3, 4, 5]
  |> map(|x| x * 2)
  |> filter(|x| x > 5)
  |> sum()

// Pattern matching with guards
match user_input {
    n if n > 0 => "positive",
    0 => "zero",
    1..=10 => "small range",
    _ => "other"
}

// Collections
let mut map = HashMap()
map.insert("key", "value")
map.get("key").unwrap()

Quality Engineering

Code Quality Standards

  • Complexity Limits: Functions must have cyclomatic complexity ≤10
  • Zero SATD Policy: No TODO/FIXME/HACK comments allowed
  • Lint Compliance: All clippy warnings treated as errors
  • Pre-commit Hooks: Automated quality gates prevent regressions

Testing

  • Unit tests for core functionality
  • Integration tests for CLI commands
  • Property-based testing for mathematical invariants
  • Fuzz testing for edge case discovery

Quality Gate Script

# Run quality checks
./scripts/quality-gate.sh src

# Checks performed:
# - Function complexity ≤10
# - No technical debt comments
# - All tests passing

Development

# Clone repository
git clone https://github.com/paiml/ruchy.git
cd ruchy

# Build
cargo build --release

# Run tests
cargo test

# Check quality
./scripts/quality-gate.sh src

# Install locally
cargo install --path .

Documentation

Related Projects

License

MIT OR Apache-2.0