Basis is an open-source, typed language for hybrid classical and quantum programs, implemented in C++20 and maintained by Akshay Pal.
The project is developing towards version 2.0. Language and compiler interfaces may
change. The current toolchain retains the .bloch source extension and bloch.lang
standard-library namespace from its predecessor.
Requirements: a C++20 compiler, CMake 3.28+, Ninja and Bash. Contributor commands also use just and clang-format 18.
git clone https://github.com/akshaysoftware/basis.git
cd basis
just build
just run examples/02_bell_state.bloch --shots=1000
just testA small program looks like this:
function main() -> void {
@tracked qubit[2] q;
h(q[0]);
cx(q[0], q[1]);
measure q;
}
From a checkout on macOS or Linux:
bash scripts/install.sh
export PATH="$HOME/.local/bin:$PATH"
basis --versionThe installer builds and tests the current checkout, then installs the executable
and bundled standard library under ~/.local. Pass an absolute prefix to change it:
bash scripts/install.sh /absolute/install/prefixRun just to list development commands and just check before opening a PR.
Development uses short-lived feature branches and squash merges into main.
The simulator's reset behaviour on entangled states requires correction. OpenQASM 2 output is an execution trace and does not preserve general measurement-dependent control flow. Sampling does not yet expose a seed option. Treat these as development limitations when evaluating results. See known issues.
Basis continues the Bloch programming-language project in its original repository. Bloch v1.0.3 accompanies the 2026 JOSS paper:
Pal, A. (2026). Bloch: a strongly typed, hardware-agnostic, hybrid quantum programming language. Journal of Open Source Software, 11(117), 9625. Paper · Archived software.
The paper describes the historical release. See CITATION.cff.