News for hackers. Stuff that matters.
Re:Ask HN: Learning C by rsheridan6 on Sunday April 26, 2009 @04:03PM (#580369)
Just about everybody who answers this will say that K&R is good, and I agree, but in addition to this I found that learning the basics of assembly was helpful. You can really see what's going on with the stack, what a pointer really is (pointers are really the only tough part about learning C, everything else will be the same old same old if you already know how to program), and the difference between a system call and a regular function call, and it doesn't take much time to learn.

Books by W. Richard Stevens were old when I was learning, and older now, but they were the best guides to taking it to the next levels. You can pick up a lot of tricks and stylistic pointers from him while learning about UNIX features and networking. Maybe somebody will chime in with a more up-to-date resource that does the same thing.

Re:Ask HN: Learning C by screwperman on Sunday April 26, 2009 @04:20PM (#580390)
I'd second this. In fact, Steve Yegge once said this about K&R ( http://steve.yegge.googlepages.com/ten-great-books ):

This is an odd little book. It's frequently mistaken for an introductory programming book, which inevitably leads to frustration. It's not a good way to learn how to program; it expects that you're already familiar with machine architecture, assembly language, compilers, and at least one other high-level language.

It's not even a very good way to learn C. The idioms and best-practices for C programming have evolved substantially, even since the second edition was published, and some of the code samples look a bit dated.

As the parent said, you'll appreciate C only if you learn about machine architecture and Unix. Diving into a large codebase will get you acquainted with "modern" C.

I've found the book C Traps and Pitfalls to be the book to get you to think like a C programmer. The C Puzzle Book is pretty good for exercises, and Expert C Programming does a good job exposing the ugly side of C.

Re:Ask HN: Learning C by jfarmer on Sunday April 26, 2009 @04:32PM (#580400)
I know the plural of anecdote is not data, but my personal experience was the opposite. C was the first programming I learned and I learned it by reading K&R in high school. I certainly didn't know anything about assembly, compilers, or another high-level language.

From there I learned by contributing to open source projects.

Not saying K&R is the best way, but it's not so opaque that a beginner with zero knowledge of C (or even programming) can't pick it up and learn if they're motivated to learn it.

Re:Ask HN: Learning C by SwellJoe on Sunday April 26, 2009 @07:56PM (#580609)
K&R was the only C book that ever allowed me to pierce the veil of mystery surrounding C and understand it. I'd tried at least a half dozen other books and was either bored out of my mind at the painfully slow pace, or utterly baffled around chapter 2 or 3 where it leapt into pointers and seemed to just assume it was obvious.

For whatever reason K&R was a perfect storm of comprehension for me, and I came away actually knowing how to read and even sort of write C (and knowing how to search the Internet, pre-Google, or ask reasonably smart questions on the mailing list or IRC channel of the software I was working with, for answers to the harder questions). I failed miserably with every other book on the subject.

Re:Ask HN: Learning C by aaronblohowiak on Sunday April 26, 2009 @04:38PM (#580403)
Re:Ask HN: Learning C by screwperman on Sunday April 26, 2009 @05:17PM (#580454)
If you enjoyed reading those 29 pages, you might find the entire book a decent read as well: http://www.amazon.com/C-Traps-Pitfalls-Andrew-Koenig/dp/0201...
Re:Ask HN: Learning C by anigbrowl on Sunday April 26, 2009 @05:12PM (#580445)
Agreed. I was scared of C for a long time, but it's actually a beautiful language. Deitel & Deitel's 'C; How to program' is a fine tutorial in both C and structured programming. YMMV.
Re:Ask HN: Learning C by davidmathers on Sunday April 26, 2009 @05:00PM (#580431)
I found that learning the basics of assembly was helpful. You can really see what's going on with the stack, what a pointer really is (pointers are really the only tough part about learning C, everything else will be the same old same old if you already know how to program)

This is key advice. Understand hardware first and pointers are obvious, don't and they are (apparently) confounding.

Re:Ask HN: Learning C by mlLK on Sunday April 26, 2009 @04:58PM (#580430)
C Programming Notes by Steve Summit should also help you get through the K&R, http://www.eskimo.com/~scs/cclass/notes/top.html; although, you'll probably get the most benefit from doing the problems/examples from K&R.
Re:Ask HN: Learning C by xenoterracide on Sunday April 26, 2009 @08:42PM (#580648)
what do you recommend for understanding assembly?
Re:Ask HN: Learning C by rsheridan6 on Sunday April 26, 2009 @09:25PM (#580683)
I used a book called "Programming From the Ground Up," which is not comprehensive but it teaches you the basics, which is really all you need for this purpose. It's online somewhere.