RustX
A clean, minimal scripting language that seamlessly integrates with Rust.
Quick Start
Install from Crates.io
Or Build from Source
Run a Script
# If installed via cargo install
# If built from source
Start REPL
# If installed via cargo install
# If built from source
Hello World
name = "World"
print(`Hello, {name}!`)
Key Features
- 🚀 Simple Syntax - Clean, Python-like syntax
- 🔗 Rust Integration - Use RustX in Rust via macros
- 📦 Rich Built-ins - 15+ built-in functions
- 🎯 Template Strings - Backtick strings with
{var}interpolation - 🔄 REPL - Interactive shell with history
- ⚡ Fast - Tree-walk interpreter written in Rust
Language Basics
Variables & Types
x = 42 // Integer
pi = 3.14 // Float
name = "Alice" // String
active = true // Boolean
items = [1, 2, 3] // Array
Template Strings
name = "Bob"
age = 25
print(`My name is {name} and I'm {age} years old`)
Method Chaining
// String methods
"hello world".upper() // HELLO WORLD
" trim me ".trim().lower() // trim me
// Array methods
[1, 2, 3].len() // 3
// Math methods
3.14.round() // 3
(-42).abs() // 42
Functions
fn greet(name) {
`Hello, {name}!`
}
fn add(a, b) => a + b // Arrow function
Control Flow
// If expression
result = if age >= 18 { "Adult" } else { "Minor" }
// Loops
for i in range(5) {
print(i)
}
while x < 10 {
x = x + 1
}
Built-in Functions
Core: print, range, len, type, push, pop
String: split, join, trim, upper, lower
Math: abs, min, max, floor, ceil, round
Rust Integration
use rx;
Documentation
Examples
Check out the examples/ directory:
basic.rsx- Variables, functions, arraysloops.rsx- For and while loopsrecursion.rsx- Recursive functionstemplate_strings.rsx- Template string interpolationmethod_chaining.rsx- Method chaining with dot operatorstring_math.rsx- String and math functions
Project Structure
RustX/
├── crates/
│ ├── core/ # Language core (lexer, parser, interpreter)
│ ├── macros/ # rx! and rsx! macros
│ └── cli/ # Command-line interface
├── examples/ # Example scripts
└── docs/ # Documentation
Contributing
Contributions welcome! Please read our contributing guidelines.
License
MIT License - see LICENSE file for details.
Made with ❤️ in Rust