Skip to content

budchirp/zep-lang

Repository files navigation

Zep

Systems programming language with manual memory management, generics, interfaces, and zero-cost abstractions. Compiles to native code via LLVM.

Features

  • Explicit ownership — values with destructors require move or .clone(); scalars copy implicitly
  • Genericsfn identity<T>(value: T) -> T, struct Container<T>
  • Interfaces — structural contracts with dynamic dispatch
  • Enums with payloadsOption<T>::Some { value: T }, Result<T, E>::Ok { value: T }
  • Struct inheritance — single inheritance with override fn
  • defer — scope-exit cleanup in reverse order
  • when — multi-branch matching with guards and destructuring
  • Primitive facades32.to_string(), "zep".to_string()
  • C FFIextern fn, extern var with variadic support
  • Zero-cost abstractions@sizeof(T), @length(array), Type.proto.fields

Example

import std.io

struct Point : Copy {
    public:
        var x: i32
        var y: i32

        fn Point(x: i32, y: i32) -> Point {
            return Point { x: x, y: y }
        }

        fn distance() -> f64 {
            return ((x * x + y * y) as f64).sqrt()
        }
}

interface Shape {
    public:
        fn area() -> f64
}

struct Circle : Shape, Copy {
    public:
        var radius: f64

        fn Circle(radius: f64) -> Circle {
            return Circle { radius: radius }
        }

        override fn area() -> f64 {
            return 3.14159 * radius * radius
        }
}

fn main() -> i32 {
    var point = Point(3, 4)
    io.printf("distance: %f\n", point.distance())

    var circle = Circle(5.0)
    io.printf("area: %f\n", circle.area())

    return 0
}

Build

Prerequisites: CMake 3.30+, Ninja, Clang with C++26 support

cmake --preset debug
cmake --build cmake-build-debug

Test

ctest --test-dir cmake-build-debug --output-on-failure

Use ctest --test-dir cmake-build-debug -N to list the currently discovered tests.

Optimize

Use -o with levels 0, 1, 2, or 3:

cmake-build-debug/cli/zep/zep build -o 2
cmake-build-debug/cli/zepc/zepc --input path/to/file.zep -o 3

Level 0 is the default. Higher levels run LLVM optimization passes before object emission.

Run

cd examples/api
../../cmake-build-debug/cli/zep/zep build
./build/api

Projects use zep.json:

{
    "name": "project",
    "version": "0.1.0",
    "type": "executable",
    "libs": {
        "std": "0.0.1"
    }
}

See DESIGN.md for the full language specification and CONTRIBUTING.md for build, test, and contribution details.

About

Zep

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors