The Unix Programming Environment
This is a review of the book The Unix Programming Environment by Brian W. Kernighan and Rob Pike.
Anyone familiar with the early days of Unix will recognise the authors as key members of the Bell Labs team that created and nurtured Unix through its early years. Brian Kernighan is rightly famous as the co-author, with Dennis Ritchie, of The C Programming Language (a similarly concise tome).
This book is slim by computer book standards, but it manages to cover a huge amount of ground. The copyright date is 1984. Don’t let that put you off, it’s still an enormously useful and very relevant book.
When I first read this book I had already been using the Xenix flavour of Unix for several years, so I wasn’t exactly a newbie.
OK, enough waffle. This is a FANTASTIC book! Reading through it for the first time, suddenly everything clicked into place and it all made a lot more sense.
The strength of this book is that it explains the philosophy of Unix, the approach and the grand design behind it all. Once you have that everything becomes much more obvious and it’s easy to see how everything fits together.
The key parts of the Unix philosophy are
- write programs to do one thing and only one thing well
- use plain text to store information in a human-readable format
- don’t use headers or footers – every line should be real data
- use pipes and redirection to combine programs to achieve your goals
The book starts with information about getting access to your Unix system and progresses logically through the file system, pipes, filters, shell programming and on to C programming. The C chapters start with using standard I/O and end up with using lex and yacc to write a programming language of similar complexity to BASIC.
Computing in 1984 meant using a VDU or, if you were not that fortunate, a hard-copy terminal to access the central computer. Home computers of the period were things like the Apple II (mainly in America I assume), and the British Broadcasting Corporation Microcomputer (in the UK).
I was attending Middlesex Polytechnic and using a DECSystem10 mainframe, so VDUs and teletype printers were familiar items. The description of powering up a terminal or using a dial-up connection seems rather quaint now, but at the time a 600 baud connection was fast.
After this first (somewhat amusing) section the text becomes much more relevant as it moves on to cover software rather than hardware
There is a fairly in-depth review of the Unix filesystem, including a discussion of i-nodes.
The pipes and filters section gives an excellent grounding in the subject and illustrates the Unix philosophy perfectly.
The book covers all the essential command line tools in a concise and informative way. If you follow the examples in the text you will end up with a bunch of useful utilities which just make your life easier. I still refer to the sections on ‘awk’ and ‘sed’ quite regularly.
Anyone from a programming background will find this book an excellent introduction to Unix. The extra bonus is that if you follow it through to the end, you’ll have covered some sophisticated language building tools and become proficient with the C language. There is also a chapter about using nroff for document preparation. The entire book was written on a Unix system, and nroff and troff were used to process the text into a format suitable for a typesetter. The proud boast at the front of the book is that all the code within it is automatically taken from working programs.
The best guide to any technical book is the quality of its index, and this is easily one of the best indices I’ve encountered.
All in all, this book was a revelation to me.
If you would like to buy your own copy of this book, and I’d heartily recommend that you do, I encourage you to click on the Amazon link below. This is my first experiment in earning some dosh with my blog – given that no-one reads it, the chances of anyone buying the book and me getting a commission seem extremely remote to me