🚀 Raven Production Readiness Roadmap¶
Current State Analysis¶
✅ What We Have (MVP Complete)¶
- Complete lexer with all basic tokens
- Full parser for core language features
- Static type checker
- Tree-walking interpreter
- CLI tool with multiple modes
- Basic examples and documentation
❌ What's Missing for Production¶
📋 PHASE 1: Core Language Improvements (Essential)¶
1.1 Error Handling & Reporting ⭐⭐⭐⭐⭐ (CRITICAL)¶
Current Problem: Error messages lack context
Need: Rich error messages with line numbers, column numbers, and context
Error: Expected ';' after assignment
--> program.rv:5:18
|
5 | let x: int = 10
| ^ missing semicolon here
|
Help: Add ';' at the end of the statement
Implementation Checklist: - [ ] Add line/column tracking to Lexer - [ ] Add source position to all AST nodes - [ ] Create Error struct with position information - [ ] Implement error formatting with source context - [ ] Add "Did you mean?" suggestions - [ ] Color-coded error output
Files to Create/Modify:
- src/error.rs - Error types and formatting
- src/lexer.rs - Add position tracking
- src/parser.rs - Attach positions to AST nodes
- src/span.rs - Source span (line, column) tracking
Estimated Time: 1 week
1.2 Operator Precedence & Associativity ⭐⭐⭐⭐⭐ (CRITICAL)¶
Current Problem: Left-to-right parsing, no precedence
let x = 2 + 3 * 4; // Currently: (2 + 3) * 4 = 20
// Should be: 2 + (3 * 4) = 14
Need: Proper operator precedence using Pratt parsing or precedence climbing
Implementation Checklist:
- [ ] Implement precedence table
- [ ] Rewrite parse_expression() with precedence climbing
- [ ] Add parenthesized expressions support
- [ ] Support unary operators (-, !)
- [ ] Add modulo operator (%)
Precedence Table (highest to lowest):
1. Parentheses: ()
2. Unary: !, -, +
3. Multiplicative: *, /, %
4. Additive: +, -
5. Comparison: <, >, <=, >=
6. Equality: ==, !=
7. Logical AND: &&
8. Logical OR: ||
Files to Modify:
- src/parser.rs - Replace parse_expression()
- src/ast.rs - Add UnaryOp expression
Estimated Time: 3-4 days
1.3 Variable Scoping ⭐⭐⭐⭐☆ (HIGH PRIORITY)¶
Current Problem: All variables are global
Need: Block-level scoping
let x: int = 10;
if (true) {
let x: int = 20; // Different x, shadows outer
print(x); // 20
}
print(x); // 10
Implementation Checklist: - [ ] Add scope stack to interpreter - [ ] Push/pop scopes on block entry/exit - [ ] Update variable lookup to search scope chain - [ ] Add scope to type checker - [ ] Support variable shadowing
Files to Modify:
- src/code_gen.rs - Add scope management
- src/type_checker.rs - Add scope checking
Estimated Time: 2-3 days
1.4 Function Calling ⭐⭐⭐⭐⭐ (CRITICAL)¶
Current Problem: Functions can be declared but NOT called!
Need: Function call expressions
fun add(a: int, b: int) -> int {
return a + b;
}
let result: int = add(5, 10); // ← This doesn't work yet!
print(result);
Implementation Checklist:
- [ ] Add FunctionCall expression to AST
- [ ] Parse function call syntax: name(arg1, arg2)
- [ ] Type check function calls (arg count, arg types)
- [ ] Implement function execution in interpreter
- [ ] Support return values
Files to Modify:
- src/ast.rs - Add Expression::FunctionCall
- src/parser.rs - Parse function calls
- src/type_checker.rs - Validate calls
- src/code_gen.rs - Execute calls
Estimated Time: 3-4 days
1.5 Arrays/Lists ⭐⭐⭐⭐☆ (HIGH PRIORITY)¶
Status: Core array support is implemented in the reference interpreter (1D and multi-dimensional types, literals, indexing, assignment, len(), and common array methods).
Need (historical sketch; syntax below is illustrative):
let numbers: int[] = [1, 2, 3, 4, 5];
print(numbers[0]); // 1
let length: int = len(numbers); // 5
Implementation Checklist:
- [x] Add array type to type system (including nested [][] / [][][] types)
- [x] Parse array literals [1, 2, 3]
- [x] Parse array access arr[index] and chained arr[i][j] / arr[i][j][k]
- [x] Implement array indexing
- [x] Add len() built-in function
- [x] Support array assignment arr[i] = value and nested arr[i][j] = value
Files to Create/Modify:
- src/ast.rs - Add array expressions
- src/type_checker.rs - Array type checking
- src/code_gen.rs - Array runtime support
Estimated Time: 1 week
1.6 string Operations ⭐⭐⭐☆☆ (MEDIUM PRIORITY)¶
Need: string manipulation
let name: string = "Raven";
let len: int = len(name); // 5
let first: string = name[0]; // "R"
let upper: string = uppercase(name); // "RAVEN"
Implementation Checklist: - [ ] string indexing - [ ] string slicing - [ ] string concatenation (already have +) - [ ] Built-in string functions
Estimated Time: 3-4 days
📋 PHASE 2: Standard Library Foundation¶
2.1 Built-in Functions System ⭐⭐⭐⭐⭐ (CRITICAL)¶
Need: Infrastructure for built-in functions
Core Built-ins Needed:
// Type conversion
int(value)
float(value)
string(value)
bool(value)
// I/O
print(value)
println(value)
input(prompt: string) -> string
// Collections
len(collection) -> int
push(array, value)
pop(array) -> value
// Math
abs(n: int) -> int
pow(base: int, exp: int) -> int
sqrt(n: float) -> float
min(a: int, b: int) -> int
max(a: int, b: int) -> int
// string
uppercase(s: string) -> string
lowercase(s: string) -> string
trim(s: string) -> string
split(s: string, delim: string) -> [string]
Implementation Checklist:
- [ ] Create src/builtins.rs
- [ ] Register built-ins in interpreter
- [ ] Type check built-in calls
- [ ] Implement each built-in function
Files to Create:
- src/builtins.rs - Built-in function registry
- src/stdlib/mod.rs - Standard library module system
Estimated Time: 1 week
2.2 Module System ⭐⭐⭐⭐☆ (HIGH PRIORITY)¶
Need: Import/export mechanism
// math.rv
fun add(a: int, b: int) -> int {
return a + b;
}
// main.rv
import math;
let result: int = math.add(5, 10);
Implementation Checklist:
- [ ] Parse import statements
- [ ] File resolution system
- [ ] Module caching
- [ ] Namespace management
- [ ] Circular import detection
Files to Create:
- src/module.rs - Module loader and resolver
- stdlib/ - Standard library modules directory
Estimated Time: 1-2 weeks
2.3 Standard Library Modules¶
2.3.1 io Module¶
import io;
let content: string = io.read_file("data.txt");
io.write_file("output.txt", content);
let line: string = io.read_line();
Functions:
- read_file(path: string) -> string
- write_file(path: string, content: string) -> void
- read_line() -> string
- file_exists(path: string) -> bool
2.3.2 math Module¶
import math;
let pi: float = math.pi;
let result: float = math.sin(1.57);
let rounded: int = math.round(3.7);
Constants:
- pi, e
Functions:
- sin, cos, tan
- sqrt, pow, abs
- floor, ceil, round
- min, max
2.3.3 string Module¶
import str from "str";
let upper: string = string.uppercase("hello");
let parts: [string] = string.split("a,b,c", ",");
let joined: string = string.join(parts, "-");
Functions:
- uppercase, lowercase
- split, join
- trim, starts_with, ends_with
- replace, contains
2.3.4 collections Module (Advanced)¶
import collections;
let map: Map<string, int> = collections.new_map();
map.set("age", 25);
let age: int = map.get("age");
let set: Set<int> = collections.new_set();
set.add(5);
📋 PHASE 3: Advanced Features¶
3.1 Structs & Methods ⭐⭐⭐⭐☆¶
struct Person {
name: string;
age: int;
}
fun Person.greet(self) -> void {
print(self.name);
}
let p: Person = Person { name: "Alice", age: 25 };
p.greet();
3.2 Enums ⭐⭐⭐☆☆¶
enum Color {
Red,
Green,
Blue
}
let c: Color = Color.Red;
3.3 Pattern Matching ⭐⭐⭐☆☆¶
match value {
0 => print("zero"),
1 => print("one"),
_ => print("other")
}
3.4 Error Handling ⭐⭐⭐⭐☆¶
enum Result<T, E> {
Ok(T),
Err(E)
}
fun divide(a: int, b: int) -> Result<int, string> {
if (b == 0) {
return Result.Err("Division by zero");
}
return Result.Ok(a / b);
}
📋 PHASE 4: Tooling & Developer Experience¶
4.1 REPL ⭐⭐⭐⭐☆¶
Implementation: - [ ] Line-by-line parsing - [ ] Persistent state - [ ] History support - [ ] Tab completion
Estimated Time: 3-4 days
4.2 Package Manager ⭐⭐⭐⭐☆¶
# raven.toml
[package]
name = "my_project"
version = "0.1.0"
[dependencies]
http = "1.0"
json = "0.5"
4.3 Formatter ⭐⭐⭐☆☆¶
4.4 Linter ⭐⭐⭐☆☆¶
Checks: - Unused variables - Dead code - Style violations - Potential bugs
4.5 Language Server Protocol (LSP) ⭐⭐⭐⭐☆¶
For IDE support: - Autocomplete - Go to definition - Find references - Inline errors - Hover documentation
📋 PHASE 5: Performance & Compilation¶
5.1 Bytecode VM ⭐⭐⭐⭐⭐¶
- See
docs/compilation_guide.md - 5-10x performance improvement
- Estimated Time: 1-2 weeks
5.2 JIT Compilation ⭐⭐⭐⭐☆¶
- Runtime compilation to machine code
- 50-100x performance improvement
- Estimated Time: 2-3 months
5.3 AOT Compilation (LLVM) ⭐⭐⭐⭐⭐¶
- Compile to native executables
- Maximum performance
- Estimated Time: 2-3 months
🎯 Recommended Implementation Order¶
Immediate (Next 2 Weeks):¶
- ✅ Error reporting with line numbers (Week 1)
- ✅ Operator precedence (Week 1)
- ✅ Function calling (Week 2)
- ✅ Variable scoping (Week 2)
Short Term (Next Month):¶
- ✅ Arrays/Lists
- ✅ Built-in functions
- ✅ string operations
- ✅ REPL
Medium Term (2-3 Months):¶
- ✅ Module system
- ✅ Standard library (io, math, string)
- ✅ Structs
- ✅ Bytecode VM
Long Term (3-6 Months):¶
- ✅ Enums & pattern matching
- ✅ Error handling (Result type)
- ✅ Package manager
- ✅ LSP server
- ✅ LLVM backend
📊 Priority Matrix¶
| Feature | Priority | Difficulty | Impact | Time |
|---|---|---|---|---|
| Error reporting | ⭐⭐⭐⭐⭐ | Medium | High | 1 week |
| Operator precedence | ⭐⭐⭐⭐⭐ | Medium | High | 3 days |
| Function calling | ⭐⭐⭐⭐⭐ | Medium | Critical | 4 days |
| Variable scoping | ⭐⭐⭐⭐☆ | Medium | High | 3 days |
| Arrays | ⭐⭐⭐⭐☆ | Medium | High | 1 week |
| Built-ins | ⭐⭐⭐⭐⭐ | Easy | High | 1 week |
| Module system | ⭐⭐⭐⭐☆ | Hard | High | 2 weeks |
| REPL | ⭐⭐⭐⭐☆ | Easy | Medium | 4 days |
| Bytecode VM | ⭐⭐⭐⭐⭐ | Hard | Very High | 2 weeks |
| Structs | ⭐⭐⭐⭐☆ | Hard | High | 2 weeks |
🎓 Next Steps¶
Start with this order:
- Error Reporting - Makes development much easier
- Operator Precedence - Fixes critical bug
- Function Calling - Makes language actually useful
- Variable Scoping - Prevents bugs
- Built-in Functions - Enables real programs
- Arrays - Essential data structure
After these 6 features, Raven will be genuinely useful for real programs!
Total estimated time for "production ready" core: 6-8 weeks