As compelling as new languages like Rust are for building systems, C and C++ remain fundamental for writing applications that run close to the metal, despite the waxing and waning of their usage statistics.
What's more, the culture of tools for C/C++ development remains deep and fruitful. Here are five C-related projects -- compilers, libraries, and support tools -- that caught our eye recently, whether for bolstering existing projects or starting new ones.
The compilation process for C/C++ programs can take a long time. Ccache was created to relieve some of that burden. As the name implies, it's a cache that saves compiled code for reuse if it hasn't changed between compilation runs, so the longer it runs with a given project, the greater the speedup. It works on a file-by-file basis, and it employs a simple MD4 hash algorithm to determine if a given file needs to be recompiled. Some command-line switches for compilers aren't supported, but in any case where ccache isn't sure about what to do, it falls back to the original compiler.
The "T" stands for "tiny," and "CC" stands for "C compiler." They're not kidding about the "tiny" part: one binary distribution of this C99-compatible compiler is a mere 1.5MB. Not only small, TCC is also fast; simple C applications compile and run under it in a split second, fast enough that you could use C apps as scripts. TCC shouldn't be relied on to generate production binaries -- it doesn't perform a lot of the more sophisticated optimizations that other C compilers do -- but it can prototype C apps without undue wait time.
For Visual Studio Code fans, there's an unofficial extension for one-click compile-and-run from that editor. For a fun example of how TCC can be embedded in other projects, check out this repository of tiny games written in C that bundle TCC as a runtime.
Cpi is essentially TCC for C++ fans: a superfast C++ compiler that allows modest C++ programs to be executed as if they were scripts. Insert a shebang at the top of a script and a
CompileOptions: directive in the body of the script, and cpi can run it on demand like a PHP interpreter runs a PHP script. Cpi can generate standalone binaries if needed, and it even includes a REPL-like interactive mode (although I wouldn't try to use it for anything more robust than quick-and-dirty scripting).
If you're determined to use C for pure speed in web applications, consider a the kcgi library. It provides a set of primitives for receiving HTTP requests, parsing them, returning headers and bodies, and getting and setting cookies. Kcgi also takes some steps to protect the system from attack, as it parses requests in a sandboxed subprocess. This does impose some overhead, as opposed to using a totally untrusted framework, but not all that much. One minor drawback: It hasn't yet been ported to Windows. For now, it's strictly Unix-family OSes.
There's crucial overlap between Python and C: The stock Python interpreter is written in C and can accept C extensions. To that end, a number of projects can bridge the gap between the two. Pycparser is one of them, but not to run C per se. Instead, it provides a pure-Python implementation of a C language parser. It forms part of the underpinning for the cffi library, which is an alternative to Python's ctypes for leveraging C code from within Python. You wouldn't want to run Pycparser if performance is a must, but it comes in huge handy if you want to leverage Python's flexibility and wealth of libraries to analyze a C code base.