Skip to Content
Guides

Getting started & CLI

Install the cpl toolchain, run programs locally, and compile submittable C++17.

You can try CP Lang immediately with zero setup in the browser playground, or install the local cpl CLI to run programs natively, emit standalone C++17 for online judges, and enable editor support (cpl lsp).

Install

From the first release, one line installs a prebuilt binary. That release is not out yet, so this command does not work today:

curl -fsSL https://cp-lang.org/install.sh | sh              # latest stable release
curl -fsSL https://cp-lang.org/install.sh | sh -s -- --edge  # newest build of main that passed every check

Until then, build cpl with Rust. It compiles CP Lang programs to standard C++17 (any g++ or clang++ that supports -std=c++17).

cargo install --locked --git https://github.com/ryanbai1412/cp-lang cpl-cli

Verify the installation:

cpl --version
cpl --help

Write, run, and compile your first program

Save this example as sum.cp:

let n: 1..=2e5 = read()
domain V = 1..=n
let a: [V]Int = read()
print(a.sum())

Check types, run directly with the local interpreter, or compile to a standalone C++17 submission:

cpl check sum.cp
printf '5\n3 1 4 1 5\n' | cpl run sum.cp
cpl build sum.cp -o sum.cpp
g++ -std=c++17 -O2 sum.cpp -o sum
printf '5\n3 1 4 1 5\n' | ./sum

The output is 14.

cpl build writes a single self-contained .cpp file with your original .cp source preserved as a comment header at the top, unused library code tree-shaken away, and @alt / @check / @interactor blocks stripped so the file is clean and ready to upload to any judge.

Editor support (cpl lsp)

The cpl CLI ships with a built-in Language Server Protocol server (cpl lsp) powered by the same incremental frontend as cpl check. Point your editor's LSP client at cpl lsp for real-time diagnostics, hover types, and completion while writing .cp files.

What works today

CP Lang is in beta. cpl check, cpl run, cpl build, cpl stress, cpl lsp and the trace viewer all work, in the CLI and in the browser. Parts of the standard library are still being implemented: an example on this site marked check-only passes the type checker but does not run yet.

Next: the course for your language, the cheat sheet, the language tour, or the C++17 migration guide.

On this page