C*

C* (pronounced "C star") is a C-based hybrid low-level/high-level programming language focused on runtime performance and developer productivity (in this order of priority). The language is simple and unopinionated, supporting imperative, generic, data-oriented, functional, and object-oriented programming.

Performance

C* compiles to efficient native code using LLVM. There's no garbage collection, hidden allocation, or runtime. C* takes a performance-first approach to common programming patterns, such as subtyping (tagged unions), map/filter/reduce (lazy iterators), and string/array handling (slices). Even fast compilation is a goal of C*.

Expressiveness

C* is a simple yet expressive language, featuring a strong type system with compile-time null-safety, sum types, and trait-like interfaces. It has both high-level programming constructs and support for systems-level programming, such as pointers, destructors, and generics. There's no preprocessor, macros, or metaprogramming.

Productivity

C* has great C interop: C headers can be imported directly without the need for bindings. The clean and familiar C-like syntax avoids unnecessary boilerplate, and allows C/C++ programmers to instantly get productive without a steep learning curve. Debug builds check for buffer or arithmetic overflows by default.

Example code

// A recursive directory listing program, demonstrating the usage of C APIs.

import "dirent.h";

void listdir(string name, int indent) {
    var dir = opendir(StringBuffer(name).cString());
    if (!dir) return;
    defer closedir(dir);

    while (var entry = readdir(dir)) {
        if (entry.d_name == "." || entry.d_name == "..")
            continue;

        var path = name + '/' + entry.d_name;
        println(" ".repeat(indent), path);

        if (entry.d_type == DT_DIR) {
            listdir(string(path), indent + 4);
        }
    }
}

void main() {
    listdir(".", 0);
}