Live data from Hacker News

Ask HN: Should I use K&R to learn C?

news.ycombinator.com

21–30 of 70 posts

Re: Ask HN: Should I use K&R to learn C?

#21
post #20

You should definitely have a copy of K&R on your desk. A book I read alongside K&R was "Illustrating C" by Donald G. Alcock, even though it is out of print and quite hard to find I'd recommend hunting a copy down as it explains the concepts visually and for me, it was the only book that made things fall into place. http://www.amazon.com/Illustrating-C-Ansi-Iso-Version/dp/052...

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

Re: Ask HN: Should I use K&R to learn C?

#22
post #4

There 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,…

If your goal in learning C is to write largish systems in it, then yes, "Learning C The Hard Way" is a good option. But the poster has said that s/he wants to learn for the purpose of reverse engineering. From this point of view, the main interest of C is just learning enough syntax to be able create functions and structs, and then compile them with gcc -S, so that you can see the assembly language that is generated by the compiler.

Personally I feel that pretty much any of the typically-cited C books are too heavy for this purpose. What you really want is a Learn C in 21 Days type of book, that will walk you through the build system as well as the basic of the C language. Even that may be too heavy - a well-written online tutorial would probably be a superior solution. Sadly, I haven't needed to look at "Intro to C" material for a very long time, so I can't really comment on what might be appropriate resources available these days.

Re: Ask HN: Should I use K&R to learn C?

#25

I would recommend "A Reference Manual" by Harbison and Steele jr over K&R... But to be honest, if you want to do reverse engineering, I would instead pick up a copy of "80386 Programmer's Manual" from Intel as you'll be living in assembly.

Did a quick search and found it: http://www.logix.cz/michal/doc/i386/

I must ask though and I don't mean this in a challenging way but isn't this teaching ASM for an old cpu? I'm largely ignorant of ASM so feel free to correct me. I just don't see the point of learning asm for that (As I believe that ASM changes from cpu to cpu).

Re: Ask HN: Should I use K&R to learn C?

#26
post #20

You should definitely have a copy of K&R on your desk. A book I read alongside K&R was "Illustrating C" by Donald G. Alcock, even though it is out of print and quite hard to find I'd recommend hunting a copy down as it explains the concepts visually and for me, it was the only book that made things fall into place. http://www.amazon.com/Illustrating-C-Ansi-Iso-Version/dp/052...

"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 used today and if OP wants to exploit such bugs, then all information is useful!

You mention nostalgia, and yes that is certainly one of the reasons as in my opinion the preface, the preface to the second edition and the introduction in the K&R book are worth the cost alone.

Besides, the book is so thin and flexible and makes a perfect ultra-portable, high-definition, long-life, skills acquisition device that works well on bus journeys, flights etc. ;)

I would say owning it is better than not.

Re: Ask HN: Should I use K&R to learn C?

#27
post #8

K&R is a great book however I feel there are better books these days. My two personal recommendations are C Programming A Modern Approach by K N King (2nd edition) and Programming in C by Kochan. However the exercises in K&R are excellent so make sure you do them all. Actually the cost of K&R is justified just for the exercises IMHO. Also get Understanding and Using C Pointers by Richard Reese, it is a must have. Two…

Seconding Understanding and Using C Pointers by Richard Reese and 21st Century C, but more for after you've gone through a more basic resource. I haven't looked at Kim King's book, but if it's anywhere near as good as his intro to Modula-2, it will be excellent to learn C from.

Re: Ask HN: Should I use K&R to learn C?

#28
post #4

There 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?

#30
Since you describe yourself as a programming newbie, I think you should take a look at Head First C. I'm not the hugest fan of the Learn __ the Hard Way approach anymore, and I think the Head First series does a good job of teaching you in an interesting and easy to remember way.

I can't speak to what you need for reverse engineering, so I'll let others say whether it's appropriate for that.

Post reply on HN