Where C Runs
C is a compiled programming language used in systems, embedded software and libraries that need control over representation and memory. Its runtime and library requirements depend on the environment.
Identify which parts of a program depend on its operating system and hardware.
The radio chip in your phone, the kernel of the server that sent you this page, and the Python interpreter many people learn first have something in common: large parts of them are written in C. A language designed in the early 1970s is still the default wherever software sits close to the machine. In this course you will grow one small program, a logger for a greenhouse sensor board, and it is exactly the kind of job C was made for.
The rule
Reach for C when every byte, cycle and wire matters.
C gives you three things that few languages give together:
- Control of memory. You decide how big each value is and where it lives. No garbage collector moves things behind your back.
- Predictable speed. C compiles straight to machine code. There is no interpreter or virtual machine between your program and the processor.
- A universal interface. Almost every language can call a C function, so C is the glue between systems.
That combination explains where C shows up:
| Area | Examples |
|---|---|
| Operating systems | The Linux kernel, large parts of Windows and macOS internals |
| Embedded devices | Thermostats, car sensors, washing machines, our greenhouse board |
| Language runtimes | CPython, the standard Ruby interpreter, Lua |
| Databases | SQLite, PostgreSQL, Redis |
| Networking and tools | The nginx web server, the curl command-line tool |
Here is the first line our logger will ever have. It is tiny, and on the board it costs only a few bytes of memory:
int reading_count = 0; /* how many temperatures we have logged */
