Coda is a statically typed configuration language that compiles to JSON.
JSON is flexible but it is not a programming language. It cannot express logic, reuse, or constraints without external tooling. Coda exists to replace ad-hoc JSON generation with a small, typed language that produces plain JSON as output. The inputs are readable source files and the output is standard JSON that fits into existing tooling.
This project focuses on a simple compiler pipeline, predictable evaluation, and diagnostics that point to exact source spans. It is intentionally minimal and does not aim to be a general-purpose language.
#= minimal example =#
type server
{
id: int;
name: string;
tags: [string];
}
fn make_server(id: int, env: string) -> server
{
server {
id = id,
name = "srv-" + env + "-" + string(id),
tags = ["coda", env]
}
}
mutable var servers: [server] = [];
mutable var i = 1;
while i <= 3
{
servers.push(make_server(i, "prod"));
i = i + 1;
}
emit { "infrastructure" = servers };
typedefines a structural type.fndefines a function with an explicit return type.if,while, andreturnbehave as in most expression-based languages.emitproduces the JSON output for the program.
A formal writeup of the syntax is in the works.
Coda runs a multi-pass pipeline:
- Parse: build an unbound AST
- Collect: collect top-level symbols
- Bind: bind symbol references
- Type-check: validate types and constraints
- Evaluate: execute and collect emissions
All passes run inside the coda executable. The current implementation is a
tree-walking interpreter. The pipeline is explicit, and each pass is a separate
component, which makes it easy to reason about correctness and error reporting.
Use the CMake presets. Debug presets are for local development.
cmake --list-presets# macOS/Linux (clang)
cmake --preset unixlike-clang-debug
cmake --build --preset unixlike-clang-debug
./out/build/unixlike-clang-debug/src/coda path/to/file.coda# macOS/Linux (gcc)
cmake --preset unixlike-gcc-debug
cmake --build --preset unixlike-gcc-debug
./out/build/unixlike-gcc-debug/src/coda path/to/file.coda# Windows (MSVC)
cmake --preset windows-msvc-debug-developer-mode
cmake --build --preset windows-msvc-debug-developer-mode
out\build\windows-msvc-debug-developer-mode\src\coda.exe path\to\file.codaOutput defaults to stdout. Write to a file with -o:
./out/build/unixlike-clang-debug/src/coda path/to/file.coda -o output.jsonShow the version:
./out/build/unixlike-clang-debug/src/coda --versionctest --preset test-unixlike-clang-debugThe snapshot test executor uses Catch2. Fixtures live in test/fixtures.
See CONTRIBUTING.md for local setup, style, and PR guidance.
