Live data from Hacker News

Ask HN: Learning C

news.ycombinator.com

11–20 of 66 posts

Re: Ask HN: Learning C

#11

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 a…

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-l…

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

#12

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 a…

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-l…

C Traps and Pitfalls: http://www.literateprogramming.com/ctraps.pdf

Re: Ask HN: Learning C

#13
You should learn C. It is a small language but to master it requires a lot of work for a reason: you need to get good at design. When all you have in your hands are structures and pointers you absolutely need to develop the ability to design well organized programs in different layers of abstractions, otherwise to scale over the 1000 lines of code program is almost impossible. This is probably the most valuable thing C will teach to you.

Re: Ask HN: Learning C

#14
Chances are you already know C, but don't realize it. Java and PHP have mostly C syntax. All you have to do is substract objects and add pointers.

Like rsheridan6 said, assembly helps. It's not necessary though, as long as you realize a pointer is actually a memory address and not something abstract like a reference in Java or PHP.

Re: Ask HN: Learning C

#16

Chances are you already know C, but don't realize it. Java and PHP have mostly C syntax. All you have to do is substract objects and add pointers. Like rsheridan6 said, assembly helps. It's not necessary though, as long as you realize a pointer is actually a memory address and not something abstract like a reference in Java or PHP.

... and figure out how to deal with allocating and freeing things. Taken together, pointers, and manual memory management are a big chunk to bite off. The syntax isn't the problem, in other words.

Re: Ask HN: Learning C

#17
1. K&R - an absolute essential. I found myself in your shoes about two years ago, picked this up, and worked through it.

2. "The Unix Programming Environment" (http://www.amazon.com/Unix-Programming-Environment-Prentice-...) This is a recent find, but covers more application. It's almost a Part 2 of K&R and covers building problems and the Unix signal and file APIs. The examples are in an ancient syntax, but part of the fun is coding them and getting them to compile.

3. "The C Puzzle Book" (http://www.amazon.com/Puzzle-Book-Alan-R-Feuer/dp/0201604612) I found this one day at Fry's, and it's fucking awesome. You can effectively learn C using it without a compiler.

Good luck!

Re: Ask HN: Learning C

#18

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 a…

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

#19

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 a…

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.

Post reply on HN