Yun is a lightweight, dynamically typed programming language designed for simplicity and expressiveness. Built following the principles outlined in Crafting Interpreters, Yun provides an intuitive syntax for rapid prototyping and learning, supporting classes, inheritance, modules, and arrays.
- Dynamic Typing: Variables are declared without type annotations (
let x = 42). - Classes and Inheritance: Object-oriented programming with dynamic fields via
selfand automaticinitinvocation. - Modularity: Import and export functionality with
useandexport. - Arrays and Loops: Convenient array manipulation and iteration (
for,while). - Block Scoping: Local variables are confined to their scope.
- Clone the repository:
git clone https://github.com/yourusername/yun.git
- Ensure Rust and Cargo are installed.
- Build the project:
cd yun cargo build --release - Run an example:
cargo run -- examples/blocks.yun
Shows class creation and inheritance with method overriding.
class Person {
init(name) {
self.name = name;
}
greet() {
print "Hello, " + self.name;
}
}
class Worker < Person {
init(name) {
super.init(name);
}
work() {
print self.name + " is working...";
}
greet() {
super.greet();
}
}
let worker = Worker("Gregory");
worker.greet(); // Hello, Gregory
worker.work(); // Gregory is working...
Yun is interpreted in Rust, adhering to Crafting Interpreters principles. The parser converts code into an AST, and the interpreter executes it, supporting dynamic typing, classes, modules, and closures.
Distributed under the MIT License. See LICENSE for details.