4 ms·
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.
by rsheridan6 18y ago
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.
- screwperman 18y agoI'd second this. In fact, Steve Yegge once said this about K&R ( http://steve.yegge.googlepages.com/ten-great-books 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.
- jfarmer 18y agoI 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.
- SwellJoe 18y agoK&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.
- aaronblohowiak 18y agoC Traps and Pitfalls: http://www.literateprogramming.com/ctraps.pdf http://www.literateprogramming.com/ctraps.pdf
- screwperman 18y agoIf 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/0201179288/ref=sr_1_1?ie=UTF8&s=books&qid=1240780543&sr=8-1 http://www.amazon.com/C-Traps-Pitfalls-Andrew-Koenig/dp/0201...
- anigbrowl 18y agoAgreed. 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.
- mlLK 18y agoC Programming Notes by Steve Summit should also help you get through the K&R, http://www.eskimo.com/~scs/cclass/notes/top.html 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.
- davidmathers 18y agoI 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.
- xenoterracide 18y agowhat do you recommend for understanding assembly?
- rsheridan6 18y agoI 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.