Clear code that compiles to C.

A small, statically typed language. The compiler checks your code and writes C; GCC builds the native program.

Cuarzo is experimental and changes often.

shapes.cz
enum Shape do
    CIRCLE(f64 radius)
    RECT(f64 width, f64 height)
end

func area(Shape shape) f64 do
    match shape do
        when CIRCLE(radius) then
            return 3.14159 * radius * radius
        when RECT(width, height) then
            return width * height
    end
end

Shape[] shapes = [Shape.CIRCLE(1.5), Shape.RECT(2.0, 3.0)]
for shape in shapes do
    print(f"area: {area(shape):2}")
end
$ cuarzo run shapes.cz
area: 7.07area: 6.00

Errors that point at the line

The compiler checks every type before it writes any C. Each error names the file, line and column, often suggests the fix, and has a code you can look up.

At run time, an index out of bounds or a missing map key stops the program and prints the calls that led there.

$ cuarzo check report.cz
[ERROR E0236] report.cz:3:7: Unknown variable 'totl'; did you mean 'total'?
[ERROR E0167] report.cz:9:12: Cannot initialize 'int' with 'str'
Cuarzo runtime error: array index out of bounds
    at report.cz:14 in average
    at report.cz:20

One command for every step

Building, formatting, linting, testing, editor support and debugging all ship in the same binary.

cuarzo run app.cz        build and run a program
cuarzo build app.cz      build a native program
cuarzo c app.cz          translate a program to C
cuarzo check app.cz      report errors without building
cuarzo fmt               lay out code in the canonical way
cuarzo lint app.cz       warn of likely mistakes
cuarzo test              run the tests of *_test.cz files
cuarzo lsp               the language server for editors
cuarzo dap               the debug adapter for editors

A standard library, also in Cuarzo

Import it as std/<name>. The compiler carries it, so there is nothing else to install.

Browse the standard library

std/term
colors, the cursor, tables, boxes and text layout
std/args
command-line options and subcommands, with generated help
std/prompt
questions, arrow-key menus, spinners and progress bars
std/fs
paths, files and directories
std/json
reading and writing JSON
std/process
running commands and collecting what they write
std/http
HTTP and HTTPS requests
std/async
tasks with timeouts, cancellation and waiting for several

Build it from one C file

The repository carries the compiler already translated to C. GCC is all you need to build it.

git clone https://github.com/cuarzolang/cuarzo
cd cuarzo
gcc bootstrap/cuarzo.c -o cuarzo -lm
./cuarzo run examples/fibonacci.cz

Read the getting started guide