Language
C
- First appeared
- 1972
- Paradigm
- Imperative, procedural
- Toolchain
- GCC 14.2
- Container image
debian:trixie-20261027-slim + gcc-14 14.2.0-19
C came out of Bell Labs in 1972, written to build the Unix operating system, and most of computing still rests on it: Python, R, PostgreSQL, and the core of NumPy are all written largely in C. Here it is compiled with GCC using the C17 standard, with every warning turned into an error.
Its standard library is small. It has sqrt, log, and exp, qsort for
sorting, and printf for output, but no growable arrays, no hash tables,
no CSV reader, and no string type beyond an array of characters. So the
implementations do their own bookkeeping: they grow arrays with realloc,
split lines with strtok, and release memory with free, because nothing
does it for you.
Quirks
- The math functions live in a separate library. Without
-lmon the compile line, a call tologfails with “undefined reference tolog”. - An array passed to a function arrives as a bare pointer, so it forgets its
length.
sizeofon a three-intarray gives 12 bytes where it’s declared, and 8, the size of a pointer, inside the function. 7 / 2is integer division, giving 3, and-7 / 2gives −3: C rounds toward zero.- Unsigned numbers wrap around: an
unsigned intholding 0, minus 1, is 4294967295. Sizes and counts (size_t) are unsigned, so a loop that counts down to 0 needs care.
Concepts in C
- Cross-validation
- Decision tree
- Descriptive statistics
- k-means clustering
- k-nearest neighbors
- Linear regression
- Logistic regression
- Naive Bayes
- Principal component analysis
Run the examples locally
You need Docker and Python 3. The harness builds the pinned container and runs every C example:
git clone https://github.com/qnixon/dswithx.git
cd dswithx
python3 harness/run_tests.py --language c