Discussion:
Should I Study K&R Second Edition?
(too old to reply)
s***@gmail.com
2017-02-17 07:46:58 UTC
Permalink
Raw Message
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?

Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)

I am asking so because then I Could get list of changes from C89 TO C99 And Update Myself , I am very confused in this regard.
Keith Thompson
2017-02-17 08:30:01 UTC
Permalink
Raw Message
Post by s***@gmail.com
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?
Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)
I am asking so because then I Could get list of changes from C89 TO
C99 And Update Myself , I am very confused in this regard.
K&R2 covers the 1989/1990 version of C. Each edition of the standard
includes a summary of the differences from the previous edition. See
N1256 for C99, N1570 for C11.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Richard Kettlewell
2017-02-17 08:36:22 UTC
Permalink
Raw Message
Post by Keith Thompson
Post by s***@gmail.com
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?
Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)
I am asking so because then I Could get list of changes from C89 TO
C99 And Update Myself , I am very confused in this regard.
K&R2 covers the 1989/1990 version of C. Each edition of the standard
includes a summary of the differences from the previous edition. See
N1256 for C99, N1570 for C11.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Those aren’t really great choices for someone who wants to start
learning C...
--
http://www.greenend.org.uk/rjk/
Andy Walker
2017-02-17 11:22:14 UTC
Permalink
Raw Message
[...]
Post by Richard Kettlewell
Post by Keith Thompson
K&R2 covers the 1989/1990 version of C. Each edition of the standard
includes a summary of the differences from the previous edition. See
N1256 for C99, N1570 for C11.
[...]
Post by Richard Kettlewell
Those aren’t really great choices for someone who wants to start
learning C...
Doesn't that depend on where the OP wants to start learning C from?
A rank beginner needs an explanatory text, but someone who already knows,
say, Java, Python and Lisp reasonably well might prefer quite a formal
description of C. An experienced C++ user might be interested in getting
back to C. And so on.

Personally, I have a problem with programming texts that try to ram
a philosophy down your throat. The language itself may be fine, but you're
forever wanting to shake the author by the lapels and say "No, programming
isn't like that!" Language standards [mostly] don't try to preach, so I
find them much easier to read.
--
Andy Walker,
Nottingham.
Richard Kettlewell
2017-02-17 11:25:16 UTC
Permalink
Raw Message
Post by Andy Walker
Post by Richard Kettlewell
Post by Keith Thompson
K&R2 covers the 1989/1990 version of C. Each edition of the standard
includes a summary of the differences from the previous edition. See
N1256 for C99, N1570 for C11.
[...]
Post by Richard Kettlewell
Those aren’t really great choices for someone who wants to start
learning C...
Doesn't that depend on where the OP wants to start learning C from?
A rank beginner needs an explanatory text, but someone who already knows,
say, Java, Python and Lisp reasonably well might prefer quite a formal
description of C. An experienced C++ user might be interested in getting
back to C. And so on.
Possibly, but I’d expect such a person to ask “where’s the spec?” rather
than asking about a particular textbook, so I don’t think it’s likely
in this case.
--
http://www.greenend.org.uk/rjk/
Keith Thompson
2017-02-17 16:03:07 UTC
Permalink
Raw Message
Post by Richard Kettlewell
Post by Keith Thompson
Post by s***@gmail.com
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?
Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)
I am asking so because then I Could get list of changes from C89 TO
C99 And Update Myself , I am very confused in this regard.
K&R2 covers the 1989/1990 version of C. Each edition of the standard
includes a summary of the differences from the previous edition. See
N1256 for C99, N1570 for C11.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
Those aren’t really great choices for someone who wants to start
learning C...
I was suggesting reading the forewords, which contain a summary of the
changes from the previous edition.
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Tim Rentsch
2017-02-17 14:17:16 UTC
Permalink
Raw Message
Post by s***@gmail.com
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?
Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)
I recommend both K&R second edition and the original K&R.
The orginal K&R might be better as an introductory text
as long as you know that there are important differences
relative to the second edition (and so to C89). But the
second edition of K&R is better in terms of being in step
with C89.

My understanding is that K&R second edition is very nearly
the same as C89 (also known as ANSI C), except that there
are some minor differences because there were some late
changes to C89 after K&R second edition was finished. I
haven't compared them myself so I can't say for sure that
they are different, but you might want to keep that in mind
while reading K&R.

C89, aka ANSI C, is essentially identical to C90, the
first ISO C standard. The documents are different in
that they use different section numbering, but other
than that I believe there are no significant differences
between them.
Keith Thompson
2017-02-17 16:07:55 UTC
Permalink
Raw Message
Tim Rentsch <***@alumni.caltech.edu> writes:
[...]
Post by Tim Rentsch
I recommend both K&R second edition and the original K&R.
The orginal K&R might be better as an introductory text
as long as you know that there are important differences
relative to the second edition (and so to C89). But the
second edition of K&R is better in terms of being in step
with C89.
I don't think I'd recommend K&R1 except for historical interest.
Post by Tim Rentsch
My understanding is that K&R second edition is very nearly
the same as C89 (also known as ANSI C), except that there
are some minor differences because there were some late
changes to C89 after K&R second edition was finished. I
haven't compared them myself so I can't say for sure that
they are different, but you might want to keep that in mind
while reading K&R.
I think that later printings of K&R2 were updated to reflect the
published C89 standard.
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Kaz Kylheku
2017-02-18 02:42:45 UTC
Permalink
Raw Message
Post by Keith Thompson
[...]
Post by Tim Rentsch
I recommend both K&R second edition and the original K&R.
The orginal K&R might be better as an introductory text
as long as you know that there are important differences
relative to the second edition (and so to C89). But the
second edition of K&R is better in terms of being in step
with C89.
I don't think I'd recommend K&R1 except for historical interest.
The saving grace of that recommendation is that there is still a fair
bit of old-style C code out there. It might be good for a new user
not to be fazed when they encounter

func(a, b, c)
int a;
char b;
double c;
{
}

just as you yourself are not.

Tough call. To someone who will never work with that, it's somewhat of a
waste of time (other than for your aforementioned historic interest).
--
TXR Programming Lanuage: http://nongnu.org/txr
Music DIY Mailing List: http://www.kylheku.com/diy
ADA MP-1 Mailing List: http://www.kylheku.com/mp1
James Kuyper
2017-02-18 02:57:15 UTC
Permalink
Raw Message
...
Post by Kaz Kylheku
Post by Keith Thompson
I don't think I'd recommend K&R1 except for historical interest.
The saving grace of that recommendation is that there is still a fair
bit of old-style C code out there. It might be good for a new user
not to be fazed when they encounter
func(a, b, c)
int a;
char b;
double c;
{
}
just as you yourself are not.
Implicit int wasn't dropped until C99, and K&R style function
definitions are still allowed, so that doesn't constitute a reason for
going all the way back to K&R1.
Keith Thompson
2017-02-18 03:27:01 UTC
Permalink
Raw Message
Post by James Kuyper
...
Post by Kaz Kylheku
Post by Keith Thompson
I don't think I'd recommend K&R1 except for historical interest.
The saving grace of that recommendation is that there is still a fair
bit of old-style C code out there. It might be good for a new user
not to be fazed when they encounter
func(a, b, c)
int a;
char b;
double c;
{
}
just as you yourself are not.
Implicit int wasn't dropped until C99, and K&R style function
definitions are still allowed, so that doesn't constitute a reason for
going all the way back to K&R1.
And K&R2 does cover the old style in section 1.7 (while strongly
recommending the new style).
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Kaz Kylheku
2017-02-18 15:14:16 UTC
Permalink
Raw Message
Post by James Kuyper
...
Post by Kaz Kylheku
Post by Keith Thompson
I don't think I'd recommend K&R1 except for historical interest.
The saving grace of that recommendation is that there is still a fair
bit of old-style C code out there. It might be good for a new user
not to be fazed when they encounter
func(a, b, c)
int a;
char b;
double c;
{
}
just as you yourself are not.
Implicit int wasn't dropped until C99, and K&R style function
definitions are still allowed, so that doesn't constitute a reason for
going all the way back to K&R1.
No, indeed; if you use an ISO standard as your tutorial, and pay close
attention, then this material will be covered.

Which *textbooks* cover this well, though?
David Brown
2017-02-18 11:08:28 UTC
Permalink
Raw Message
Post by Kaz Kylheku
Post by Keith Thompson
[...]
Post by Tim Rentsch
I recommend both K&R second edition and the original K&R.
The orginal K&R might be better as an introductory text
as long as you know that there are important differences
relative to the second edition (and so to C89). But the
second edition of K&R is better in terms of being in step
with C89.
I don't think I'd recommend K&R1 except for historical interest.
The saving grace of that recommendation is that there is still a fair
bit of old-style C code out there. It might be good for a new user
not to be fazed when they encounter
It seems perfectly reasonable to me that a new user should be fazed by
code like that. Teaching that stuff to new students is like having
trainee car mechanics do a course on horse buggy repairs. Yes, there
/are/ some horse buggies around, and occasionally someone will need to
look at one or fix it - but it is rare enough that it is not worth
learning about it if you are not specialising in maintaining outdated code.

It is enough to tell people that such function definitions existed
historically - it is covered in a paragraph. Then you can go back to
teaching them about how they should write their code. A book that
teaches this style of C coding is /outdated/ and of historical interest
only - it is not a book to read to learn about C programming.
Post by Kaz Kylheku
func(a, b, c)
int a;
char b;
double c;
{
}
just as you yourself are not.
Tough call. To someone who will never work with that, it's somewhat of a
waste of time (other than for your aforementioned historic interest).
Tim Rentsch
2017-02-19 09:34:15 UTC
Permalink
Raw Message
Post by Keith Thompson
[...]
Post by Tim Rentsch
I recommend both K&R second edition and the original K&R.
The orginal K&R might be better as an introductory text
as long as you know that there are important differences
relative to the second edition (and so to C89). But the
second edition of K&R is better in terms of being in step
with C89.
I don't think I'd recommend K&R1 except for historical interest.
My recommendation is for both, not for just K&R by itself. Also
I'm not saying someone should read the original first, only that
it might be better as an introductory text. And it might -
most likely different readers will reach different conclusions
on that question.
Post by Keith Thompson
Post by Tim Rentsch
My understanding is that K&R second edition is very nearly
the same as C89 (also known as ANSI C), except that there
are some minor differences because there were some late
changes to C89 after K&R second edition was finished. I
haven't compared them myself so I can't say for sure that
they are different, but you might want to keep that in mind
while reading K&R.
I think that later printings of K&R2 were updated to reflect the
published C89 standard.
The point is not to assume that the two are the same. We don't
know which printing will end up on the reading table.
Keith Thompson
2017-02-19 15:19:02 UTC
Permalink
Raw Message
[...]
Post by Tim Rentsch
Post by Keith Thompson
I don't think I'd recommend K&R1 except for historical interest.
My recommendation is for both, not for just K&R by itself. Also
I'm not saying someone should read the original first, only that
it might be better as an introductory text. And it might -
most likely different readers will reach different conclusions
on that question.
Would you care to expand on your reasons for recommending both?

[...]
Post by Tim Rentsch
Post by Keith Thompson
I think that later printings of K&R2 were updated to reflect the
published C89 standard.
The point is not to assume that the two are the same. We don't
know which printing will end up on the reading table.
It's easy enough to check which edition you have.
--
Keith Thompson (The_Other_Keith) kst-***@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Tim Rentsch
2017-02-24 23:16:18 UTC
Permalink
Raw Message
Post by Keith Thompson
[...]
Post by Tim Rentsch
Post by Keith Thompson
I don't think I'd recommend K&R1 except for historical interest.
My recommendation is for both, not for just K&R by itself. Also
I'm not saying someone should read the original first, only that
it might be better as an introductory text. And it might -
most likely different readers will reach different conclusions
on that question.
Would you care to expand on your reasons for recommending both?
Not especially, but I will anyway. :)

One reason is that less material is easier to absorb, and the
original edition covers less material (kind of obviously, because
the language is smaller). Similar to the difference between a
tutorial and a reference manual - someone new to the language can
benefit from both.

Another reason is that C has a long history, which even today is
occasionally relevant looking at existing code. I believe there
are benefits to being exposed to the style of earlier C code, and
the original K&R naturally does a better job of that than K&R2.

Needless to say, I realize that other people may hold different
views on the subject.
Post by Keith Thompson
Post by Tim Rentsch
Post by Keith Thompson
I think that later printings of K&R2 were updated to reflect the
published C89 standard.
The point is not to assume that the two are the same. We don't
know which printing will end up on the reading table.
It's easy enough to check which edition you have.
Yes, if you have the book in your hands, and if you know which
printings have the updates in them. I'm not sure either applies
to the person who asked the orginal question.

James Kuyper
2017-02-17 16:15:22 UTC
Permalink
Raw Message
Post by s***@gmail.com
I wanted to start Learning C From A Nice Book Which I Never Did,
So I was wondering if I Should Start From K&R Second Edition?
Is that equivalent to C89 Or there Are Any Changes? (Yes I Mean C89)
I am asking so because then I Could get list of changes from C89 TO C99 And Update Myself , I am very confused in this regard.
K&R is an excellent book for learning C. The fact that it teaches you an
old version of C counts against it - but some people are still sticking
to C90 nearly two decades after it was officially replaced by C99. You
won't go far wrong by sticking with K&R until you understand the
language well enough to learn about the updates that have occurred since
it was released from some other more modern book.
I've been told that it's not as good a book for people who are learning
computer programming for the first time as it is for those who have
learned at least one other programming language. I wouldn't know about
that - by the time I read K&R, I was already familiar with Fortran I,
APL, and Basic.
Loading...