cx (stylized as lowercase, not to be confused with languages called CX or Cx) is a C-family 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, supporting imperative, generic, data-oriented, functional, and object-oriented programming. It compiles to efficient native code via LLVM or the C backend, with no garbage collection or hidden runtime.
Note
The project is nearing its 0.1 release: there are still some planned features that haven't been implemented yet, and the currently implemented features are subject to change, and there are bugs.
To learn more about the language, visit the website:
For more code samples, see examples.
You can also read the language documentation in Markdown format under docs.
To ask a question or open a discussion, create an issue or join the cx Discord server.
The cx extension for VS Code provides syntax highlighting and language server features.
Prebuilt Linux, macOS, and Windows binaries are published on the releases page
(the fastest install on Linux/macOS is curl https://cx-language.github.io/cx/install.sh | bash).
To compile from source, see Building from source.
For diagnostics, hover, go to definition, completions, find references, and semantic highlighting
in any LSP-capable editor, see the editor setup guide.
The cx-lsp binary is built alongside cx.
Contributions are welcome. Compiler internals for contributors live in
docs/internals.md.
See the GitHub issues and the Trello board for the project backlog.
Install lit and its optional dependencies via pip:
python3 -m pip install lit psutilOn Windows, spell it py -m pip install lit psutil instead
(python -m pip ... works too). See the Windows checklist
for the rest of the Windows setup.
Some examples have extra prerequisites; see the README in each example directory for details.
Then invoke the following from the build directory:
cmake --build . --target checkConfigure with -DCMAKE_BUILD_TYPE=Release for running tests, since the
unoptimized compiler is several times slower per test invocation.
With the Visual Studio generator on Windows, CMAKE_BUILD_TYPE is ignored;
build and test the Release configuration instead:
cmake --build . --config Release --target checkThis runs the full suite via CTest: the lit/compiler tests, the example programs (LLVM and C backends),
the documentation snippets, and the language server end-to-end tests.
Run a subset from the build directory with e.g. ctest -R 'docs-snippets'
(use double quotes in cmd.exe).
To run a single compiler test file, invoke lit with the flags shown by ctest -N -V.
The C++ code style is enforced by ClangFormat:
- Run the
formatCMake target to format the code. - Run the
lintCMake target to check if the code is formatted.
To work on the browser playground or the website, see wasm/README.md
(architecture, building, and testing of the WebAssembly frontend and the in-browser C toolchain).
Run website/build-website.sh --serve to develop the website locally.
cx is licensed under the MIT license, a permissive free software license. See the file LICENSE.txt for the full license text.
