C* is a language designed for performance and productivity.
C* (pronounced “C star”) is a 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, has a clean C-like syntax, and supports imperative, generic, data-oriented, functional, and object-oriented programming.
// 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);
}