Saturnus(https://camo.tmpim.com/5eeb023f770afe5955ddc5903138e5207aed786b/68747470733a2f2f6769746875622e636f6d2f7369676d61736f6c646933722f53617475726e75732f7261772f6d61696e2f646f63732f6c6f676f5f7265616c69737469632e706e67)
The main Saturnus repository can be found on github: https://github.com/sigmasoldi3r/Saturnus (https://github.com/sigmasoldi3r/Saturnus)
Saturnus is a programming language that aims to have a simplified
mix of Rust programming language and Lua.
The original purpose of this language was to provide an easy-to-learn syntax, and fast compilation times, to replace Lua scripts currently.
Beware that the compiler is under
alpha stage, that means that the pure core-most features are working, but there are some bugs/missing features, like trailing commas throwing a compilation error, missing range generation/linear for... They're pointed out in the repo's readme.
Contributions are welcome!! If you find a bug/missing feature, open an issue.
Key points of the language that might be a little bit disruptive, if you come from lua:
- All statements must end with a semicolon (eg: let i = 0;)
- Concatenation operator is ++ (eg "a" ++ "b")
- Method dispatching uses dot when lua uses :, and static dispatch uses :: when lua uses a dot
How does it look?You can find some examples at the folder /examples of the repo (https://github.com/sigmasoldi3r/Saturnus/tree/main/examples)!
But, here you have some brief examples:
// Here is how decorators work in Saturnus:
fn MakeArcane() {
// You return a function,
// and that will decorate the target class.
return (target) => {
target.prototype.kind = "ARCANE";
};
}
// One of the advantages of Saturnus over Lua,
// is that you can have decorator code generation:
@MakeArcane()
class Mundane {
let kind = "mundane";
fn what_kind_is(self) {
return self.kind;
}
}
let mundane = Mundane {/* Use default constructor fields */};
// If you run the output you'll be surely suprised:
print("My mundane thing is in fact: " ++ mundane.what_kind_is());
Don't like the classness of the language? You can revert back to only-functions programming also!
Remember: Saturnus does not care if you embed everything into classes or not, you can also create programs like in the old Lua fashion:
let i = 0;
fn plus_one() {
i += 1;
}
fn how_many() {
return i;
}
fn sum_and_tell() {
plus_one();
return how_many();
}
print("Summing one: " ++ sum_and_tell());
print("Summing one: " ++ sum_and_tell());
print("Summing one: " ++ sum_and_tell());
// Also your typical table literals:
let player = {
health: 100,
hurt: (self, amount) => {
self.health -= amount ?? 1;
}
};
print("Player's health: " ++ player.health);
print("Hurt 10");
player.hurt();
print("Now: " ++ player.health);
Tell me if you want more examples! (I'm working on a repository with many more scripts that are currently running on my server)
Also, I've pushed some artifacts, in case you don't want to compile by yourself. You can find them at the workflow resulting artifacts. (https://github.com/sigmasoldi3r/Saturnus/suites/14475231680/artifacts/817789831)