Comparison with related languages

Many languages compete in the space of fast, natively compiled software, and each makes different trade-offs:

cx aims to balance the control and performance of a low-level language together with the expressiveness of a higher-level one (compile-time null safety, method call syntax, closures, generics with interface bounds, operator overloading, tagged unions, and a capable standard library), while keeping the language small and approachable.

cx C++ Rust
Null T? types with auto-narrowing Pointers always nullable, std::optional, no safety Option, explicit Some(...)
Sum types Tagged unions via enum std::variant + visitor helper Tagged unions via enum
Errors Result Exceptions, std::expected Result
C interop import "foo.h", no bindings Native Manual extern declarations
Build cx build, implicit module tree Headers + external build system Cargo, explicit module tree
Safety Debug checks + leak detector built in, sanitizers planned Opt-in sanitizers Proven by the borrow checker

cx vs C

cx is heavily based on C and is in many ways compatible with it: C headers can be imported directly and cx functions can be declared extern "C" to be callable from C, so cx can be adopted gradually alongside existing C code.

What cx adds over C:

When to pick C: the tradeoff is language/ecosystem maturity vs modern expressiveness/developer ergonomics. C is standardized, time-tested, and available everywhere, while cx is a still-evolving language with a richer feature set designed for day-to-day productivity and joy of programming.

cx vs C++

"Within C++, there is a much smaller and cleaner language struggling to get out." - Bjarne Stroustrup

cx is trying to be that language. It keeps what C++ gets right: deterministic destruction, generics, function overloading, close-to-the-metal performance with no garbage collector, and the principle of paying only for what you use. It changes the parts of C++ that cost productivity:

When to pick C++: cx imports C headers directly, but C++ API interop is a longer-term goal, so C++ code currently needs C wrappers to be callable from cx. And where C++ has decades of standard library, tooling, and compiler maturity, cx is still young.

cx vs Rust

Rust and cx share many features (tagged unions via enum, Result-based error handling, generics with bounds, a standard build tool), but make opposite choices about how much correctness to demand up front:

When to pick Rust: if you need guaranteed memory or thread safety, pick Rust.

cx vs Zig

Zig is a more low-level-focused language, competing primarily with C. cx is more of a hybrid low-level/high-level language, competing primarily with C++.

When to pick Zig: if you want every allocation, error, and control-flow path spelled out explicitly, or need Zig's cross-compilation toolchain, Zig is the better fit.

cx vs Odin

Odin is the closest in spirit of the newer systems languages: pragmatic, C-like, manually managed memory with no garbage collector or exceptions, defer, multiple return values, and slices, maps, and dynamic arrays built in. The differences:

When to pick Odin: Odin is further along: it is stable, documented, and used in production. cx is younger and still evolving.

cx vs Jai


  1. https://boats.gitlab.io/blog/post/2017-01-04-the-rust-module-system-is-too-confusing/↩︎