A lightweight interpreted programming language built in Go, designed for embeddability, runtime scripting, and extensibility.
Most applications eventually require:
- Runtime scripting
- Dynamic business rules
- Modding systems
- Configuration logic
- Embedded automation
- Hot-reloadable behavior
Traditional approaches usually rely on:
- Hardcoded logic
- External scripting runtimes
- Unsafe eval systems
- Heavy embedded languages
This introduces several issues:
- Tight coupling between app logic and runtime behavior
- Difficult extensibility
- Unsafe execution environments
- Increased deployment friction
- Poor control over embedded execution
Moxy solves this by providing:
- A lightweight interpreted language
- Easy Go integration
- Runtime script execution
- Safe sandboxed evaluation
- Embeddable scripting capabilities
It enables developers to add programmable behavior into applications without requiring recompilation.
Source Code
β
βΌ
βββββββββββββββββββ
β Lexer β
β Tokenization β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Parser β
β Builds AST β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Abstract β
β Syntax Tree β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Evaluator β
β Runtime Engine β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Runtime Objects β
β Env / Scope β
βββββββββββββββββββ
The lexer converts raw source code into tokens.
Example:
let x = 10 + 20;
Becomes:
LET IDENT ASSIGN INT PLUS INT SEMICOLON
Responsibilities:
- Token recognition
- Keyword parsing
- Operator handling
- String/int parsing
- Whitespace skipping
The parser transforms tokens into an AST (Abstract Syntax Tree).
Example:
1 + 2 * 3
AST:
(+)
/ \
(1) (*)
/ \
(2) (3)
Responsibilities:
- Pratt parsing
- Operator precedence
- Expression parsing
- Statement parsing
- Syntax validation
The AST represents the program structure independent of execution.
Node types include:
- Let statements
- Return statements
- Function literals
- Call expressions
- If expressions
- Array literals
- Hash maps
- Loops
This separation makes future compiler/bytecode support easier.
The evaluator walks the AST and executes code.
Responsibilities:
- Expression evaluation
- Scope resolution
- Function execution
- Runtime object creation
- Control flow execution
Supported runtime types:
- Integers
- Booleans
- Strings
- Arrays
- Maps
- Functions
- Null
Moxy uses scoped environments for variable resolution.
Global Scope
β
βββ Function Scope
β β
β βββ Nested Scope
This enables:
- Closures
- Lexical scoping
- Function isolation
- Runtime safety
- Variables
- Arithmetic operations
- Boolean expressions
- Conditionals
- Functions
- Arrays
- Hash maps
- Loops
- Built-in functions
let fibonacci = fn(n) {
if (n < 2) {
return n;
}
return fibonacci(n - 1) + fibonacci(n - 2);
};
print(fibonacci(10));
- Go
- Custom AST
- Pratt Parser
- Recursive Evaluator
- Go Modules
- CLI Runtime
- REPL Support
Although Moxy is currently an interpreted language, the architecture is intentionally designed for future scalability.
The AST layer enables future support for:
- Bytecode compilation
- JIT execution
- Static analysis
- Optimization passes
without rewriting the parser.
Moxy can be embedded directly into Go applications:
engine := moxy.New()
engine.Execute(script)This enables:
- Game scripting
- Plugin systems
- Workflow engines
- Runtime automation
The runtime is intentionally isolated from direct system access.
Benefits:
- Safer embedded execution
- Controlled APIs
- Reduced attack surface
Future capability-based permissions can extend this further.
- Lightweight runtime
- Simple architecture
- Easy embeddability
- Beginner-friendly interpreter design
- Extensible language core
- Interpreted execution is slower than compiled runtimes
- No static typing
- No bytecode VM yet
- Limited standard library
- Garbage collection relies on Go runtime
let nums = [1, 2, 3, 4];
let sum = fn(arr) {
let total = 0;
for (x in arr) {
total = total + x;
}
return total;
};
print(sum(nums));
Source code becomes tokens.
Tokens are transformed into AST nodes.
Evaluator recursively walks the AST.
Objects/functions/scopes are created dynamically.
10
- Better error handling
- Improved REPL
- Module system
- File imports
- Standard library expansion
- Bytecode compiler
- Virtual machine (VM)
- Performance optimizations
- Debugger support
- Package manager
- JIT compilation
- WASM target
- Concurrency primitives
- Native FFI bindings
- Language server support (LSP)
Most embedded scripting systems are either:
- Too heavy
- Too unsafe
- Too difficult to customize
Moxy aims to provide:
A lightweight, hackable, embeddable language runtime for modern Go applications.
It serves as both:
- A practical embeddable scripting engine
- A deep exploration into language/runtime engineering
- A foundation for future VM and compiler experimentation