Marslang#
An interpreted language with a Rust interpreter. A .mars program is parsed, resolved, and run directly β no JavaScript, no Node, no bytecode step in between.
takepkg std.math;
fixed hot pi (float) = 3.14159;
family Circle{
func init(float r){
me.r = r;
}
func size(){
ret pi * math.pow(me.r, 2);
}
}
func m{
shapes (array[float]) = arr(1.0, 2.5, 4.0);
for (r, shapes){
out(Circle(r).size());
}
}
What the language gives you#
Numbers that say what they are
int is a checked 32-bit value, longint is 64-bit, float is a double. Overflow raises instead of wrapping, and comparisons work across kinds.
Containers that keep their promise
An annotation such as array[int] is enforced on every insertion, atomically: a rejected value leaves the container exactly as it was.
Strings measured in characters
Length, iteration, slicing, search, and padding all count grapheme clusters, so Γ©, δΈ, and π¨βπ©βπ§βπ¦ each count as one.
Packages, the familiar way
takepkg loads bundled standard packages, your own module files, package directories with init.mars, and relative imports such as takepkg .sibling;.
Errors you can catch by kind
run { } handle(TypeError e) { } then { }, with error families rooted at Error and err(type, message) to raise your own.
Memory that is reclaimed
Reference counting plus a trial-deletion cycle collector, so containers that point at each other are freed rather than leaked.
Install#
One command, no Rust toolchain, nothing written outside your home directory:
irm https://marslang.kevin-z.com/install.ps1 | iex
curl -fsSL https://marslang.kevin-z.com/install.sh | sh
Each script downloads the build for your platform, checks it against the
release's SHA256SUMS, puts marslang on your PATH, and creates
marslang_pkgs in your home directory, where packages you install are imported
from. --use std,ext picks the package sets; std is built into the
interpreter. To build from source instead, clone the repository and run
cargo build --release.
Run a program#
Write hello.mars:
func m{
out("hello from marslang");
}
Run it, or check it without running:
marslang hello.mars
marslang check hello.mars
marslang pkgs prints the directory that installed packages come from.
m is the entry point. Syntax errors, unknown names, and reassignment of a fixed
binding are reported before anything runs; a runtime error prints
error: <Kind>: <message> and exits with status 1.
The standard library#
Standard packages are written in Marslang itself, on a small set of native Rust primitives, so the language exercises its own semantics:
- std.math β 51 functions and six constants.
- std.containers β stack, queue, deque, priority queue.
- std.strings β splitting, searching, trimming, case, padding.
- std.types β a value's kind and family checks.
- std.time β clocks and sleeping.
- std.Decorator β
@Decorator.privateand@Decorator.subclass.
Where it stands#
The Rust interpreter is the implementation; the language is not self-hosted yet.
There is no static type checker and no native backend. The remaining decorators
(static, class, overload), match, and async are unimplemented. The
reference marks what is available today, and every release is
listed under releases.