A TypeScript-inspired language runtime built in Rust for a custom language called RTS (Rusty TypeScript).
Rusty compiles RTS code into bytecode and executes it on a custom virtual machine, with an upcoming WebAssembly (WASM) backend for near-native performance — without relying on JavaScript engines like V8.
Modern TypeScript execution looks like:
TS → JS (tsc) → V8 (Node/Bun/Deno) → JIT → machine code
This introduces:
- heavy runtime overhead
- unpredictable JIT optimizations
- large memory footprint
Rusty explores an alternative:
RTS → Bytecode → Lightweight VM
↘
WASM (future)
👉 A lightweight, controllable execution model 👉 No dependency on V8 or Node.js 👉 Portable and embeddable runtime
Rusty currently uses a bytecode interpreter with a frame-based VM:
Source Code → Lexer → Parser → AST → Compiler → Program → VM
↓
main bytecode + function table
↓
Frame-based execution (call stack)
| Stage | What it does |
|---|---|
| Lexer | Tokenizes raw source into tokens |
| Parser | Builds an AST with proper precedence |
| Compiler | Emits stack-based bytecode, separates functions |
| VM | Executes bytecode using a value stack + call frames |
Rusty is evolving toward a dual execution model:
RTS → AST → Bytecode → VM
↘
WASM → near-native execution
The WASM backend will:
- ⚡ improve execution speed for compute-heavy workloads
- 📦 enable portable execution across environments
- 🎯 provide predictable performance (no JIT warmup)
- 🔌 allow embedding in browsers, servers, and edge runtimes
- 🧠 Custom lexer, parser, and AST
- ⚡ Bytecode compiler with separate function compilation
- 🧮 Frame-based stack virtual machine
- ➕ Arithmetic with precedence and parentheses
- 📝 String literals and concatenation (
"hello" + " world") - ➖ Unary operators (
-x,-(2 + 3)) - 🔀 Comparison operators (
>,<,==,!=) for numbers and strings - 🔗 Logical operators (
&&,||) with short-circuit evaluation - 🔁 Control flow (
if/else) with backpatching - 🔄 Loops (
while,for) withbreak/continue - 🔢 Increment / decrement (
i++,i--) - 🔧 Functions with parameters, return values, and recursion
- 🧩 Nested function calls (
add(add(1,2), 3)) - 📦 Arrays (literals, index read/write, pass to functions)
- 🖨️ Print statements (
print x;) - 🔁 REPL (interactive shell)
- 📂 File execution (
rusty run file.rts) - ✅ CI pipeline (GitHub Actions)
Check out the example/ folder for sample RTS programs, including:
test.rts— array basics (literals, indexing, mutation)merge_sort.rts— merge sort implementation using arrays, functions, and recursion
Run any example with:
cargo run -- run example/merge_sort.rtsgit clone https://github.com/shubhiscoding/rusty_runtime.git
cd rusty_runtime
cargo install --path .rusty run file.rts
rusty repl
rusty --versiongit clone https://github.com/shubhiscoding/rusty_runtime.git
cd rusty_runtime
cargo buildRun locally:
cargo run -- run example/test.rts
cargo run -- repl- Variable declarations (
let) - Arithmetic expressions with precedence
- Unary operators
- Parentheses
- Print statement
- REPL
- Strings (literals, concatenation, mixed-type concat)
- Truthy/falsy values (
0and""are falsy) - Comparisons (
>,<,==,!=) for numbers and strings -
if/else -
whileloops -
break/continue - Variable reassignment
-
forloops - Logical operators (
&&,||) with short-circuiting - Increment / decrement (
++,--) - Functions (declaration, params, return)
- Nested / recursive function calls
- Frame-based call stack
- Arrays (literals, indexing, mutation)
- Array pass/return from functions
- Type annotations
- Objects / maps
- Closures
-
<=,>=operators
- Bytecode VM
- CI pipeline (build, test, clippy, fmt)
- WASM backend (in progress)
- Bytecode optimizations
- Register-based VM (optional)
- Compile TS-like syntax to WASM
- Optional native compilation (LLVM / Cranelift)
- Embeddable scripting runtime
- Standard library (
console,Math, etc.)
Rusty is an experimental runtime and:
- does not yet match V8 performance
- does not support full TypeScript
- focuses on execution model exploration
Contributions are welcome — especially in:
- language features
- error handling
- performance optimizations
- WASM backend
Steps:
- Fork the repo
- Create a branch
- Raise a issue or Pick a issue
- Submit a PR