TrapC, a new fork of the C programming language, is in development as a focused response to the longstanding memory safety challenges that have plagued C and C++. Spearheaded by developer Robin Rowe, TrapC is positioned not as a replacement but as a safer evolution of C—one that aims to modernize the language’s handling of memory without sacrificing familiarity or performance.
Described as a cybersecurity compiler extension for both C and C++, TrapC is built on the idea that memory safety should be the default, not an afterthought. Rowe envisions TrapC as a minimalist yet safer variant of C—one that borrows just enough from C++ to enhance safety through mechanisms like constructors and destructors, but not so much that it becomes difficult to learn or use. He argues that safer programming patterns shouldn’t rely on developers always remembering to check error codes or manage resources manually.
Set for release by the end of the year, TrapC will be open source and available as a compiler alternative akin to Clang. A key feature of TrapC is its introduction of memory-safe pointers, offering a solution to the risky pointer behavior that often causes critical bugs in C and C++ codebases. Developers will continue to write in familiar C or C++ syntax but compile through TrapC to benefit from improved memory management and automatic safety guarantees.
To that end, TrapC makes selective changes to the C language by removing problematic keywords like goto
and union
, while introducing safer alternatives such as trap
and alias
. It also incorporates a handful of C++ features—like member functions, constructors, and destructors—to manage object lifetimes more reliably. Despite these changes, TrapC maintains a minimal keyword count and retains a high degree of compatibility with existing C++ code. Rowe recently presented TrapC at an ISO C standards meeting and has invited feedback through a publicly available whitepaper, where he details the compiler’s design principles and goals. While not the only attempt at enhancing memory safety in the C ecosystem, TrapC seeks to distinguish itself by offering a more comprehensive and practical solution.