I'd say that K&R C is a historical relic and not the best way to learn the language anymore. I have the ANSI second edition. It's way outdated. If you have some programming language experience already I'd suggest going with 21st Century C by Ben Klemens. There's a decent refresher on the language in the appendix and most of the book spends time talking about all of the things most text books skip over: tooling, debug…
Ask HN: Should I use K&R to learn C?
51–60 of 70 posts
Re: Ask HN: Should I use K&R to learn C?
#52There was a very good critique of K&R in Learn C the Hard Way that got taken down because of (IMO) undue backlash. The gist of it was that K&R ignores the safety problems in C and there is no discussion of the habits/constructs seasoned C programmers have developed to make sure their code is safe. Of course, many of those habits were developed after K&R, but that's why we need revisions and new sources. In its place,…
I didn't know of the critique of K&R in LCTHW that got taken down. I'm surprised that the rabble-rousers weren't able to take it in context. When K&R was first authored, there were no "seasoned" C programmers from which to draw on for their experience in writing safe, secure C code!
Re: Ask HN: Should I use K&R to learn C?
#53A small detail that has been missed by most responses to the question is OP isn't asking how to learn how to write the best possible 2015 C code for 2015 C tasks, but asked for reverse engineering previously written code (perhaps written VERY long ago). Depending on the age and quality of the code OP is reverse engineering, learning a very modern style of coding might somewhat oppose OPs goal. I'd advise OP to rephra…
Re: Ask HN: Should I use K&R to learn C?
#54Earlier quoted context omitted.
"You should definitely have a copy of K&R on your desk." I ask honestly, why? Other than nostalgia and as a signal to others what does it bring the modern C programmer? I have it on my shelf, but it is part of my history.
"I ask honestly, why?" As you say yourself, it is part of your history, you've probably forgotten which concepts that K&R taught you and the OP is trying to learn C from scratch. The OP mentions that they are learning C to help them with their reverse engineering skills, so learning about the older ways that C was programmed is also invaluable as those insecure programming techniques are still (unfortunately) widely…
This weighed heaviest in my mind. K&R is a poor book to learn modern C. Its like saying a person starting out with Fortran today should learn from a book written for FORTRAN 77. It might be ok later once better habits have set in, but for someone who didn't live through that era, it just seems like a waste of time and money for learning modern C.
I am still convinced its a signal to others and an aspiration for what we want out of language authors, but it just isn't up to date for the task of being the first C book someone reads.
Re: Ask HN: Should I use K&R to learn C?
#55Re: Ask HN: Should I use K&R to learn C?
#56See it here: http://careferencemanual.com/, at its home page.
Or at Amazon here: http://www.amazon.com/Reference-Manual-5th-Edition/dp/013089....
Turn to this book when you have questions. The authors are Harbison and Steele. If you become a C programmer, you will want and need this book. So you may as well get a copy now.
Another (more advanced) book is The C Puzzle Book.
http://www.amazon.com/The-Puzzle-Book-Alan-Feuer/dp/02016046....
It's older and I'm not sure it's totally up-to-date with the latest version of C. But it's still very valuable. If you finish this book, you will be a C ninja, and it isn't too hard.
K&R is outdated, in my opinion, because it is too skimpy.
Re: Ask HN: Should I use K&R to learn C?
#57Earlier quoted context omitted.
I didn't know of the critique of K&R in LCTHW that got taken down. I'm surprised that the rabble-rousers weren't able to take it in context. When K&R was first authored, there were no "seasoned" C programmers from which to draw on for their experience in writing safe, secure C code!
Yes and no. Perhaps when the first edition was published that was true, but the second edition was published 11 years later.
Re: Ask HN: Should I use K&R to learn C?
#58Personally, I have found most C books to be colossal failures. K&R is a great text that would be good for you to read eventually (if only to see how far C has come), but to learn how to do modern programming, K&R probably is not where you should go. Additionally, LCTHW let me down significantly (regardless of what you think of the author). If I could make two recommendations to you, the first would be that reading a…
> with a mentor to guide you I wholeheartedly agree. Not to say they're mutually exclusive, but nothing comes close in terms of education / time density to an experienced programmer telling you what you did wrong and why.
Re: Ask HN: Should I use K&R to learn C?
#59Earlier quoted context omitted.
Interesting, last time I asked on various C boards about learning resources, Zed's book got ripped apart. http://www.iso-9899.info/wiki/Books
The man who moved my book into the "avoided" category admitted to me in an email that he did it just because of my K&R critique, not because of the book's quality, is not a C programmer, hasn't coded C professionally ever, and works doing PHP with almost no C experience.
Re: Ask HN: Should I use K&R to learn C?
#60If you're serious about reverse engineering, you might consider learning assembly language and C side-by-side. Learn an assembly language (with the Art of Assembly Language Programming or similar) while working through K&R (or another introduction to C), but compiling everything with gcc -S and reading the assembly output (initially, compile with -O0; optimization will obscure the output too much). This would be slow…
What you described is exactly how I want to learn C: together with ASM but wasn't sure how to go about it. But know you have gave me a general idea on how to go about it, thanks.