A compiled, memory-safe language built for clarity and safe concurrency
Pepper is in the spirit of Rust and Swift. Every struct is reference counted, exactly like C++'s std::shared_ptr, so there is no garbage collector and no ownership annotations to learn. It compiles to native code through LLVM, and it is written in Pepper.
import async;
# [Shared] lets threads share a Point: the compiler checks every field is
# const and thread-safe.
[Shared]
struct Point {
const x: int;
const y: int;
construct(this.x = 0, this.y = 0) {}
}
const total = async.Atomic<int>(0);
main(): int {
var points = [Point(1, 2), Point(3, 4)];
var threads = Array<async.Thread>();
for (var p in points) {
threads.append(async.Thread.spawn(() => { total.fetch_add(p.x * p.y); }));
}
for (var thread in threads) {
thread.join();
}
print($"total: {total.load()}");
return 0;
}
total: 14
Take [Shared] away and the build fails: the closure captures a Point, which is not thread-safe.
Why Pepper
- Memory safety without a garbage collectorReference counting with the semantics of
std::shared_ptr: values are freed when the last reference goes, at a predictable point, with nothing to annotate. - ClarityErrors in the style of clang, located at the exact token to change, and one standard format (
pepper fmt), with a language server for your editor in the toolchain. - Concurrency safetyOnly thread-safe values cross threads. The compiler checks that a
[Shared]struct's fields areconstand thread-safe, and that every module-scope variable is.
Install
# Linux and macOS
curl -fsSL https://raw.githubusercontent.com/pep-lang/pepper/main/scripts/install.sh | sh
Windows, the VS Code extension and building from source: see Install.