gitmyhub

c4

C ★ 11k updated 2y ago

C in four functions

c4 is a minimalist C compiler and interpreter written in just four C functions, a programming curiosity that can even interpret its own source code.

Csetup: easycomplexity 2/5

c4 is described as "C in four functions" and is explicitly called an exercise in minimalism. The entire project is a C compiler and interpreter, written in the C programming language itself, using only four functions to accomplish the job.

The README is intentionally sparse. It shows how to compile the project with a standard C compiler, then run it to interpret a C source file. You can also pass the c4 interpreter to itself, meaning the interpreter can run its own source code, which is a classic demonstration of self-hosting in programming language tools.

Because the README provides very little detail beyond the build and run commands, the scope of supported C features, any known limitations, and the intended audience are not described. The project appears aimed at programmers curious about how compilers work at a fundamental level, or those interested in how much can be done with very little code.

Where it fits