Learning C3
Nullability, References, and Contracts
- Strong desire for null-restricted / non-null types; several commenters see plain nullable pointers plus comment-based contracts as a step backward vs modern approaches.
- The “contracts in comments” design is controversial: some find it weird or non-idiomatic, others note it’s similar to SPARK/ACSL and like that it’s incrementally adoptable and keeps signatures clean.
- There’s an extended debate on how non-null types interact with zero-initialization (ZII), bulk allocation, and lack of constructors. Some argue you can enforce non-null by requiring initialization at declaration; others say that breaks common C-style patterns (arrays, vectors, bulk allocs).
- One view: strict non-nullability is more appropriate for “from scratch” languages than for a C-evolution like C3.
Loops, “foreach”, and Low-Level Transparency
- Concern that
foreachis “not C-like” and hides iteration mechanics (step size, pointer vs index). - Clarification:
foreachis intentionally limited to simple element-wise iteration, caching length for performance; for custom strides or mutations,forremains available. - Some argue if you’re not processing every element, you shouldn’t use
foreachanyway. Others worry any higher-level loop clashes with C3’s low-level ethos.
Positioning vs Rust, Zig, Hare, D, etc.
- Many see Rust as more complex and more like a C++ competitor; C3 aims to be “C, but better” with lower complexity and C ABI compatibility.
- C3 is contrasted with Zig/Odin/Hare/C2 as another C-adjacent option; Hare’s Unix-only focus and QBE backend are discussed as limiting factors.
- Some argue D is the “best” C/C++ evolution feature-wise, but attribute its limited adoption to size/complexity, GC history, half-finished features, and “has-been” perception.
Performance, Backend, and Tooling
- C3’s LLVM IR is designed to closely mirror Clang’s, so runtime performance is expected to match C; any difference is labeled a bug.
- A C backend is planned to help target unusual platforms and act as an escape hatch.
- Comparison with QBE: smaller and elegant but slower in end-to-end pipeline and historically lacking debug info.
Error Handling and ? Types
- One commenter prefers classic exceptions (
try/catch/finally) over pervasiveOptional/Either-style error threading. - C3’s error model combines
try/catch-like composability withT?result types and acatchbinding that implicitly unwraps on success, pitched as more ergonomic than plain result types while remaining explicit.
Switch/Case and Control Flow
- Debate over stacked
caselabels vscase X, Y:syntax. Concerns about readability with many labels; C3 stays close to C but adds case ranges. - C3 also supports an expression-style
switchthat lowers toif-else, which some find convenient and others consider too high-level/confusing in a low-level language.
Macros and Generics
- Skepticism about macros in general; concern about DSL abuse.
- C3’s macros are described as hygienic (no leaking variables into caller scope) and closer to polymorphic static inline functions than to C preprocessor tricks.
Ecosystem, Community, and Sponsorship
- Some question advantages over Rust given Rust’s larger ecosystem; others counter that C3’s instant access to C libraries is a strong form of “community support.”
- Sponsorship by a web company is seen as straightforward marketing-oriented OSS support, with no deeper entanglement mentioned.