A elegant and modern systems programming language
Lotus is a systems programming language that combines the safety philosophy of Rust, the performance of C++, and the simplicity of Go. Version 1.3.0 features an LLVM backend for multi-architecture support (x86, ARM, RISC-V, WebAssembly). Here's how to get up and running.
Choose your installation method:
yay -S lotus-lang # or git clone https://aur.archlinux.org/lotus-lang.git cd lotus-lang makepkg -si
git clone https://github.com/j-alexander3375/Lotus.git cd Lotus go build -o lotus ./src # Optionally: sudo cp lotus /usr/local/bin/
Create a file called hello.lts:
use "io";
fn int main() {
println("Hello, Lotus!");
ret 0;
}
Compile and run:
lotus hello.lts ./a.out
Or in one command:
lotus -run hello.lts
Declare variables with type first, Lotus-style:
int count = 42;
Rust-inspired import syntax with clear dependencies:
use "io";
use "math";
LLVM-powered with multi-architecture support:
lotus --target=arm program.lts
Explicit control with malloc/free and type safety:
use "mem";
int* ptr = malloc(sizeof(int));
fn int add(int a, int b) {
ret a + b;
}
fn int main() {
int result = add(5, 3);
printf("Result: %d\n", result);
ret 0;
}
// Type-first variable declaration int count = 0; string message = "Hello"; bool flag = true; // Constants const int MAX_SIZE = 100; const string VERSION = "1.0.0";
// if/else
if count > 0 {
println("Positive");
} else {
println("Non-positive");
}
// while loop
while count < 10 {
count = count + 1;
}
// for loop
for int i = 0; i < 5; i = i + 1 {
printf("%d\n", i);
}
Lotus supports Go-like printf verbs:
use "io";
fn int main() {
printf("Integer: %d\n", 42);
printf("Hex: %x\n", 255);
printf("Binary: %b\n", 15);
printf("String: %s\n", "Lotus");
ret 0;
}
Lotus comes with modular standard library:
| Module | Functions | Purpose |
|---|---|---|
io |
print, println, printf, fprintf, sprint, sprintf, sprintln | Input/output and string formatting |
mem |
malloc, free, sizeof | Dynamic memory management |
math |
abs, min, max, sqrt, pow, floor, ceil, round, gcd, lcm | Mathematical operations |
str |
len, concat, compare, copy, indexOf, contains, startsWith, endsWith | String manipulation |
num |
toInt8/16/32/64, toUint8/16/32/64, toBool | Numeric conversions |
hash |
djb2, fnv1a, crc32, murmur3, sha256*, md5* | Hashing and checksums (*placeholders) |
collections |
array/stack/queue/deque/heap, hashmap, hashset | Data structures |
net |
socket, connect_ipv4, send, recv, close | Networking (low-level) |
http |
get | HTTP client (built on net) |