Pallas is a systems programming language that combines low-level control with a safer, modern language design. This is a personal project inspired by my friend Lily's programming language, ADAN and many ideas inspired by languages like C/C++, Go, Rust and Zig.
What Pallas gives you:
- Explicit behavior
- Manual memory management
- Structs and classes
- Pattern matching
- Familiar syntax
Pallas is a personal project - Though I'd appreciate any contributions and feedback.
- Discord: @kauht or @yuhbayn
- Discord Server: https://discord.gg/WVMHUgrgeH
- GitHub: https://github.com/kauht/Pallas
- CMake
- A C++17 compatible compiler
- LLVM v14+
cmake -S . -B build
cmake --build buildbuild/palc --helpPallas uses explicitly-sized types. No implicit conversions.
| Type | Description |
|---|---|
i8, i16, i32, i64, i128 |
Signed |
u8, u16, u32, u64, u128 |
Unsigned |
f32, f64 |
Floating point |
bool |
Boolean |
char |
Character |
string |
String |
void |
No Type |
Type aliases:
| Alias | Equals |
|---|---|
int |
i64 |
uint |
u64 |
float |
f32 |
double |
f64 |
Pointers, References and Arrays:
T*- pointer toTT&- reference toTT**- pointer to pointerT[n]- array of sizen
x: i32 = 42;
const PI: f32 = 3.14159;
square(n: i32): i32 {
return n * n;
}
structs hold data only. classes support methods, constructors, and destructors.
struct Vector3 {
x: f32;
y: f32;
z: f32;
}
class Person {
public:
name: string;
age: i32;
Person(n: string, a: i32) {
name = n;
age = a;
}
~Person() {
// destructor
}
greet(): void {
println("Hello, ${name}, you are ${age} years old!");
}
private:
ssn: string;
}
if (x > 10) {
println("large");
} else {
println("small");
}
for (i: i32 = 0; i < 10; i++) {
println("${i}");
}
counter: i32 = 0;
while (counter < n) {
counter++;
}
Examples:
// static array
a: i32[4] = [1, 2, 3, 4];
for (v : a) {
println("${v}");
}
// dynamic array
v: Vec<i32> = Vec<i32>();
v.push(10);
v.push(20);
for (x : v) {
println("${x}");
}
Arena allocation:
arena(4096) {
tmp_str: string* = new string("temp"); // in arena
buf: i32* = new i32[64]; // in arena
} // all arena allocations are freed here
// Arena type for manual control
arena: Arena = Arena(8192);
p: Foo* = new(arena) Foo(...);
q: Foo* = new(arena) Foo(...);
// reuse allocations...
arena.free_all(); // free all allocations from my_arena
add(a: i32, b: i32): i32 {
return a + b;
}
main(): void {
p: Person* = new Person("Sammy", 17);
p.greet();
delete p;
}
// Generic class
class Optional<T> {
has: bool;
value: T;
Optional(v: T) { has = true; value = v; }
~Optional() { /* code */ }
is_some(): bool { return has; }
}
// Generic function
identity<T>(x: T): T {
return x;
}
// Call generic function
n: i32 = identity<i32>(42);
b: Optional<i32> = Optional<i32>(10);
res: Vector<i64> = b.map<i64>((v: i32): i64 { return (i64)v; });
// Type alias
type IntVec = Vector<i32>;
// Default type param
struct SmallVec<T = i32> {
data: T*;
len: i64;
}
// Use defaulted generic
sv: SmallVec = SmallVec(); // SmallVec<i32>
const can be used for compile-time values. Or non-mutable values that are initialized at runtime, depending on the context.
const BUFSZ: i64 = 16;
const NAME: string = "Pallas";
arr: i32[BUFSZ];
Goals:
- Finish language spec
- Complete Parser
- Complete Semantic
- Integrate LLVM
- Complete IR
- Complete Codegen
- Add tests for parser, semantics, and codegen
- Write LSP and formatter (VSCode/Zed/Neovim)
Contributions are always welcome, check out CONTRIBUTING.md for more information.
Pallas is MIT licensed - see LICENSE.
Pallas is heavily inspired by the following: