My first attempt at creating my own programming language.
Moonwalk is designed to be a simple, safe, statically typed, compiled language fully compatible with the .NET platform. It is designed to be a simple language that is easy to learn and use, while still being powerful enough to write complex programs in.
- Simple impertaive language
- Full compatibility with .NET
- Safe, statically typed, compiled language
- Modular and eas y to write and create POC
- Inline testing
For now the syntax is still in flux, but here is a simple example of what I am aiming for:
import Terminal.Gui;
module Main {
pub func Main(args: string[]): void {
Application.Init();
let label: Label = create_label("Hello, World!");
Application.Top.Add(label)
Application.Run();
Application.Shutdown();
}
prv func CreateLabel(text: string): Label {
let label = new Label(text) {
X = Pos.Center(),
Y = Pos.Center(),
Height = 1
};
return label;
}
prv func ImportExample(): void {
Utils.Print("Hello, World");
}
}
module Utils {
pub struct Person() {
Name: string;
Age: int;
init (name: string, age: int): Person {
this.Name = name;
if (age < 18) {
Console.WriteLine("Younger person");
}
this.Age = age;
}
}
pub func Print(text: string): void {
Console.WriteLine(string);
}
}
module Main.Tests {
import NUnit;
[Test]
pub func ShoudlAddTwoNumbers(): void {
let result = 1 + 1;
Assert.AreEqual(2, result);
}
}
- Building a Compiler Series by Immo Landwerth: https://www.youtube.com/watch?v=wgHIkdUQbp0&list=PLRAdsfhKI4OWNOSfS7EUu5GRAVmze1t2y
- Introduction to Compilers and Language Design by Douglas Thain: https://www3.nd.edu/~dthain/compilerbook/
- Crafting a Compiler by Charles N. Fischer, Richard Joseph LeBlanc and Ronald Kaplan Cytron: https://www.amazon.com/Crafting-Compiler-Charles-N-Fischer/dp/0136067050