I'm planning to buy a book to learn C Language. Many say K&R is a must-have book for C programmers so I chose it. I see that there are two editions. What are the differences between them?

  • 13
    Usually if a book has a 2nd edition, buying it is a no-brainer. It's the updated version of the first edition. – Adam Lear Oct 24 '11 at 4:40
  • 1
    Thanks for asking this! I have my father's first edition copy of K&R from 1978, but have been somewhat uncertain about whether or not I should just buy the second edition, with the latest printing (42nd). – Apophenia Overload Nov 19 '11 at 9:09

There may be a few cases where a first edition is preferred for some reason or other, but this is definitely not one of them.

If you want to learn C, the second edition is clearly preferred in this case. The first edition teaches a version of C that's been obsolete for decades. C has maintained enough backward compatibility that most of the code in the first edition will probably still work with a current compiler, but it's definitely not written the way you want to write C code any more.

| improve this answer | |
  • 1
    The 2nd edition is also written in a way that you wouldn't want to write C code any more. Because the original was written long before good/bad programming practice and style was even invented. – user29079 Oct 27 '11 at 14:00
  • 3
    @Lundin: Their ideas of good/bad programming practice and style may have differed from yours, but the idea had certainly been invented (and IMO, where you disagree with them on these matters, chances are much better that you're wrong than they are). – Jerry Coffin Oct 27 '11 at 14:11
  • No this isn't just my own opinion, but the opinion shared by most leading C programming experts. Pick up any code snippet from K&R and run it through a modern static analysis tool - see for yourself. They were experts in the 70s, more than 30 years ago. The computer industry, as well as computers themselves, have undergone huge changes since then. Most of the syntax in K&R, and in C itself, is obfuscated by purpose so that they wouldn't waste so much HD space to store the source code. Programmers back then thought few source code characters equals good programs, it was all they knew. – user29079 Oct 27 '11 at 19:49
  • @Lundin: Sorry, but I've yet to see a static analysis tool that seemed to be written by anybody as good as K and/or R either. If you want to get somewhere with this, you need to start by citing real data, not attempting to appeal to authority -- especially when you can't even cite an actual authority to whom you're appealing. – Jerry Coffin Oct 27 '11 at 19:55
  • Name something K&R did that wasn't pure algorithms, that still holds as good C programming practice today? Without writing code full of flaws. As for authority, MISRA-C would be the most obvious, as it is the most modern, relevant update to C, in the form of a safe subset. If you want, I can run some K&R 2nd edition code through some static analysers tomorrow and come back with a list of questionable and/or plain dangerous programming practice from some snippets in that book. – user29079 Oct 27 '11 at 20:16

The second edition is written to ANSI C, which the first predated. That alone should make the second book the one to buy.

| improve this answer | |

Definitely the 2nd version. The first version doesn't cover ANSI C.

| improve this answer | |

If memory serves me right, K&R 2nd Edition was published in 1988, to comply with the imminent release of ANSI-C (aka C89)

A lot has happened in the C world since then...

  1. 1990 - adoption of C by ISO as ISO/IEC 9899:1990 (aka C90)
  2. 1999 - new revised standard as ISO/IEC 9899:1999 (aka C99)
  3. 2011 - further major revision as ISO/IEC 9899:2011 (aka C11)

Not to mention the work of MISRA and CERT-C (etc) to produce safer subsets.

I have a copy of both editions, but seldom refer to either...

| improve this answer | |
  • 3
    Note that the 1989 ANSI and 1990 ISO C standards describe exactly the same language; the only difference between the documents is some added introductory material and a renumbering of the sections. – Keith Thompson Nov 29 '12 at 9:59
  • @KeithThompson Sir, I am Planning To Study Second Edition of the book, can you tell me the main differences it and C99 and C11 has , or point me to that question, I cannot seem to find it, I just want the differences, Does Second Edition is very outdated or still makes sense? – Suraj Jain Feb 17 '17 at 7:06
  • @SurajJain - the main differences are additions in C11 to support threads, atomics, alignment and generics - plus enhancements to complex and IEC floating point. – Andrew Feb 17 '17 at 7:17
  • @Andrew I am planning to learn C From Second Edition of k & r, i want to which changes are there in it and c99 ? , Does K&R 2nd edition means c89 or there is a difference – Suraj Jain Feb 17 '17 at 7:29
  • Without wanting to restart the discussions further above, I would not start with K&R (of either edition) - there are more up-to-date works that would be more appropriate. – Andrew Feb 17 '17 at 7:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.