OK I GIVE UP

The C Programming Language

Book cover image

Here are the reasons why this book should be required reading for all programmers

(1) First of all, this book is written in an incredibly clear and elegant style. There is rarely a sentence one has to read twice, all explanations are exactly at the right level of detail, and the code examples are perfectly trimmed for the current topic. At the beginning of the book, K&R write that they wanted C to be a language that the developer can fit in his head. This is a very worthy objective for a language, unfortunately rarely achieved even by many modern languages. The contents of this book are clearly designed to fit in the developer’s head, not necessarily in a single reading, but as one references the book and reads individual chapters once more.

(2) It is the authoritative book on C, the language in which (nearly) all the operating systems, system utilities, compilers, and intepreted language runtimes are written in. It is rarely the case that a developer looks into the code for these if she’s not a C developer herself. This book is a good exercise in understanding which considerations go into building such important programs that we all use, and which have to withstand all kinds of weird setups and exceptional situations. Even the more so, since Kernighan & Ritchie do not refrain from giving examples directly from the C standard library and Unix system libraries themselves, demystifying them in the process (at least for people like me who have exclusively used higher level programming languages like Java or Python, and never did systems programming).

(4) As the common wisdom on why C won against all the other languages that were better in many respects goes (see Art of Unix Programming), it is the language that reflects the reality of computation as realized by our computers the best, and that reality is that the computer is a band of memory on which a head can move and write – a Turing machine. This is the cold hard truth, and all the abstractions that are built above it can conceal it up to a certain degree, referring you to the gory details in case of breakdowns (e.g. insufficient memory, data corruption, memory loss due to alignment). Having a basic understanding of how this Turing machine works gives, in addition to an appreciation of how the complexity of all the software we use emerges from simple principles, another set of tools to debug the next annoying problem.

(5) In addition to C, K&R have given the world Unix, the operating system specification which is currently pretty much everywhere. C was actually the language they used to build Unix, and the initial collection of programs that ran on it. This book, despite not having Unix in the title, picks most of its examples and sample code from either Unix system tools, or software for Unix. It thus serves as a light introduction to programming on and for Unix, something most backend developers are doing these days anyway.

(5) Due to the specific way the language is designed, C requires a certain programming style. For example, heavy use of pointers and the possibility to do pointer arithmetic leads to operations on parts of strings to be done in place, instead of splitting them and copying memory in the process. Sample code makes use of common C idioms very frequently, solving problems the way they are supposed to be solved in this language. C, despite being a pretty tough language, does have its own aesthetics, and K&R certainly know where it lies.

(6) Last but not least, C is difficult, and reading about how one has to go through a hundred loops in order to do the simples things (read a complete line from a file) makes one appreciate the high level languages, libraries, and development tools we have today.