C Programming Language (2e)

Author: Brian W. Kernighan, Dennis M. Ritchie
Publisher: Prentice Hall
Pages: 272
ISBN: 978-0131103627
Print: 0131103628
Kindle: B009ZUZ9FW
Audience: Programmers who know what K&R is
Rating: 5, but with reservations
Reviewer: Harry Fairhead

This is a classic but not everyone appreciates this particular gem and perhaps they shouldn't.

This is the second edition of what used to be referred to simply as K&R, perhaps in the right circles it still is. I have to admit now that I learned C from the first edition and was enthusiastic about it, and the C language, as a result. Over the years C changed. It turned into ANSI C, C99 and C11. This second edition covers ANSI C because this is the most modern version that was available at the time it was revised - in 1988, 10 years after the original in 1978.

So why are we reviewing a 30-year old second edition? Because it's impossible to review other books on C without reference to K&R and so it fills a gap in our coverage.

The very first thing to say is that this book is the first in a long time that has made me look closely at the print quality. The title page looks as if it has been copy and pasted from the original and then photocopied a few times. At first I thought that this might be something to do with an historical homage to the first edition, but this doesn't explain the terrible blurry quality of the rest of the book. It makes you think that the book might be a pirated copy illegally printed on out of date printing machines in a third world country - except of course that it comes from Prentice Hall, now part of the Pearson group.  So you need to be prepared for this strange presentation.

Once you get over the blurry mess, the good news is that you stil get the K&R experience reading it. Notice that this is not a book for a beginner and it makes no attempt to teach you how to program, and yet in a way it sort of does. It gradually leads you into increasingly deeper water by explaining small examples of the language. 


Chapter 1 is a tutorial-style introduction to the core of the language. I remember reading the original and finding everything OK. with the possible exception of null terminated strings and that very weird for loop. What was that all about? Of course, as soon as I realized that it was a simple mapping to the sort of enumeration loop you write in assembler it all seemed reasonable - elegant even. This is a feeling that should get stronger as you read the book. However, time has spoiled the effect slightly. The trouble is that many of the elegant examples now simply bring into mind the buffer overflows that we are plagued with today. Read a string until you hit a null - but what if there is no null?! The second edition does address some of these issues.

Chapter 2 presents the fundamental data types in C. You could say that the fundamental data type for C is the bit and leave it at that, but K&R does goes over the basic units that C uses to allocate memory. C doesn't really have data types, just different ways of interpreting bit patterns stored in memory.

Chapter 3 represents the control structures introduced in the first chapter in a more formal style. It was this that made C so easy to grasp - this and the fact that C is a small language with only a few core features.

Chapter 4 is where we meet functions, the fundamental building block of C programs. It also introduces some of the more advanced ideas such as variable scope, using multiple source files, the preprocessor and so on. Chapter 5 explains pointers and 6 deals with structures and unions.

This ends the main part of the book on the core of C. From here the final two chapters deals more with the environment of the language. Chapter 7 is about the standard library, which is only standard because of ANSI. Chapter 8 is about working with the Unix file system and so on.

So does the book still work?

Is it still a classic?

Yes and no.

The true classic is the first edition. For one thing it was better printed. You can still buy secondhand copies for much less than the second edition so if it is just a trip down memory lane you desire this is the one to buy. It isn't going to do you a lot of good relating to ANSI C, but then the second edition isn't going to do you a lot of good relating to C99 or C11.

If you buy this book expecting to get a hand-holding approach to C suitable for a beginner then you are going to hate it. This is, as I said at the start, a book aimed at the programmer versed in another language - preferably Fortran or assembler. This is the audience the book was originally aimed at and if you have this background you can't help but see the point of C in making it easier to do low-level coding in a higher-level style. 

Who can I recommend this book to? Only programmers who know the reputation of the original K&R book. Any reader not aware of the heritage would simply say "A 30 year old book - you have to be kidding me?" Yet it is still a lot better than many books on C that simply presents the language as if it was a slightly modified version of Java or one of the other modern languages. C has a link to the past, just like this book.

Yet having said all of this I have to say that I think, for the right reader, it is a very quick and painless way to learn C - just like it was for me. 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.


Go Programming Language For Dummies

Author: Wei-Meng Lee
Publisher: For Dummies
Date: April 2021
Pages: 336
ISBN: 978-1119786191
Print: 1119786193
Kindle: B0921HHN48
Audience: People wanting to learn Go
Rating: 4
Reviewer: Mike James
Can a dummy master Go?

Code: The Hidden Language of Computer Hardware and Software 2nd Ed

Top Book 2023
Author: Charles Petzold
Publisher: Microsoft Press
Date: August 2022
Pages: 480
ISBN: 978-0137909100
Print: 0137909101
Kindle: B0B123P5GV
Audience: General
Rating: 5
Reviewer: Mike James
Code! We all need to know about it.

More Reviews

Last Updated ( Tuesday, 31 July 2018 )