whatisgithub

What is c4?

rswier/c4 — explained in plain English

Analysis updated 2026-06-24

10,687CAudience · developerComplexity · 2/5Setup · easy

In one sentence

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.

Mindmap

mindmap
  root((c4))
    What it does
      C compiler in C
      Interpreter runtime
      Self-hosting demo
    Minimalism
      Four functions only
      No dependencies
      Tiny codebase
    Learning value
      Compiler internals
      Parser design
      VM concepts
    Usage
      Compile with gcc
      Run C source files
      Run itself
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Compile and run c4 to understand how a minimal compiler works at a fundamental level using only four functions.

USE CASE 2

Use c4 as a learning reference to study how parsing and execution can be done in under a few hundred lines of C.

USE CASE 3

Run c4 on its own source code to see a self-hosting interpreter in action.

What is it built with?

C

How does it compare?

rswier/c4syllo/nvtopdicedb/dicedb
Stars10,68710,64210,747
LanguageCCC
Setup difficultyeasyeasyeasy
Complexity2/52/53/5
Audiencedeveloperops devopsdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

So what is it?

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.

Copy-paste prompts

Prompt 1
Walk me through the c4 source code and explain how each of the four functions works and how they chain together to compile and run C code.
Prompt 2
I want to understand how c4 implements its virtual machine. Explain the instruction set and execution loop in the source.
Prompt 3
How does c4 achieve self-hosting, running its own source file as input? Trace through what happens step by step.

Frequently asked questions

What is c4?

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.

What language is c4 written in?

Mainly C. The stack also includes C.

How hard is c4 to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is c4 for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.