arya's (ab)use of C


updated 2024-09-01

While I really enjoy programming in Rust, I have a big soft spot for C. I think the simplicity of the language gives it many advantages. I have a good intuition for how C code will be compiled into machine code (at least for x86). It is relatively easy to compile, so users can choose between different C compilers (although we usually stick to GCC and Clang), and it is a good target for implementing your own compiler. The various vender-specific extensions to C allow you to implement really interesting high-level features (e.g. true macro recursion).

Of course, there are downsides to C that actively hinder good code. Pointer aliasing is a major issue, and C's lack of insight into it prevents entire classes of optimisations. It's very difficult to idiomatically describe complex APIs in C. And the variety of build systems and compilation techniques to choose from means that the C ecosystem is heavily fragmented.

I enjoy exploring ways to improve C's expressiveness, by finding cursed ways to add new features to the language. I'm sure there's a decent way to implement concurrency in C, but I just haven't figured it out yet. I'm also interested in compiler architecture, and I think C is a good target for that due to its built-in limitations (e.g. the ordering of top-level declarations). But, at the end of the day, I'd rather write code in Rust than C.