Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
11  
Usually if a book has a 2nd edition, buying it is a no-brainer. It's the updated version of the first edition. –  Anna 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
add comment

4 Answers

up vote 12 down vote accepted

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.

share|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
2  
@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
show 11 more comments

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

share|improve this answer
add comment

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

share|improve this answer
add comment

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...

share|improve this answer
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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