C
Fifty years old, still the layer everything else is standing on.
- First released
- 1972
- Created by
- Dennis Ritchie, at Bell Labs
- Typing
- Static and weak, with free conversion through pointers
- File extensions
- .c, .h
What it is for
C lives at the bottom of the stack. Operating system kernels, device drivers, embedded firmware, language runtimes, and the standard libraries of nearly every other language. When a language advertises that it can call into native code, the interface it means is C's.
It survives because it is small and because it maps onto hardware with almost nothing in the way. No runtime, no garbage collector, few abstractions that cost anything you did not ask for. That is exactly what you want on a microcontroller with kilobytes of RAM. It is also exactly what makes it dangerous everywhere else: manual memory and unchecked buffers have supplied a remarkable share of the last three decades of security vulnerabilities.
So the newer systems languages are all defined partly in opposition to it, and serious effort now goes into replacing it where security matters. None of that dents the installed base. There is more C running today than ever, and it will outlive everyone reading this.
Where it came from
Dennis Ritchie built C at Bell Labs between 1969 and 1973, out of Ken Thompson's B, so that Unix could be rewritten in something other than assembly. That made Unix portable, and that one decision spread both the operating system and the language further than any amount of advocacy could have.
Kernighan and Ritchie's The C Programming Language, in 1978, defined the language for a decade and became one of the most influential programming books ever written. Formal standardization came later: ANSI C in 1989, ISO in 1990, then C99, C11, C17 and C23, each adding carefully and breaking almost nothing.
The committee's conservatism is the whole point. Code written in 1990 still compiles, and a C ABI is the common tongue every language can speak. C has changed less in fifty years than most languages manage in five.
What it is like to type
C is braces, semicolons and stars. Every statement ends in a semicolon, every block is a brace pair, and pointer work drops * and & into the middle of declarations and expressions where your fingers do not expect them. Header guards and #include lines make the hash key ordinary rather than exotic.
165 steps across 10 tours, from the basics to complete programs.
The tours
- Language basicsC from the beginning. 35 steps.
- Pointers & memoryThe tour C is really about. 25 steps.
- Strings & textC strings are a convention, not a type: a pointer and a promise that there is a zero byte somewhere ahead. 13 steps.
- Files & I/Ostdio, properly. 12 steps.
- Preprocessor & headersThe preprocessor is a text substitution pass that runs before the compiler has any idea what your program means, and most of C's stranger corners live here. 12 steps.
- Data structures & algorithmsData structures written out by hand, because in C that is the only way you get them. 20 steps.
- Systems programmingC talking to the operating system. 14 steps.
- Threads & concurrencyThreads in C11, plus the mutexes and condition variables that keep them from destroying each other. 10 steps.
- Unions, bitfields & undefined behaviorThe parts of C that are legal, useful, and capable of ruining your week. 13 steps.
- APIs, errors & testingHow to write C that other people can use. 11 steps.
Official documentation
- cppreference C reference
- ISO WG14, the C committee
- GCC documentation
- The GNU C Library manual
- Clang documentation