Live data from Hacker News

Learn C The Hard Way

learncodethehardway.org

11–20 of 260 posts

Re: Learn C The Hard Way

#11
post #5

Do people really think C is some mysterious, inscrutable language? "To many programmers, this makes C scary and evil." Is this actually true for people? I find C code generally very easy and straightforward to understand; there's not any magic behind the scenes, like there is in any language that's more "high level" than C.

Many of the friends I made in my CS classes were terrible with pointers. I never really understood why they didn't grasp pointers, but it was a major stumbling block for them in C/C++

Re: Learn C The Hard Way

#13
post #8

Why is %d used to interpolate an integer into a format string? I don't recall seeing this done for any reason before. I hope Zed actually covers how dangerous format strings can be if not handled properly. Format strings are still (hilariously) one of the major exploitation vectors in C-based applications today. Edit: According to Wikipedia, %i and %d are synonymous. Sorry for the confusion.

It's not for the type, but for the output. The 'd' means "decimal" output. For example, you can do %x to "hexadecimal" output, and %o for octal. Of course, there's some complex interplay with what type you hand that function.

As for how "dangerous" it is, yeah it's not going to rape your family, it'll just crash. So I'll be showing people how to prevent it.

Re: Learn C The Hard Way

#14
post #10
post #3

I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

using gdb?

Re: Learn C The Hard Way

#15
post #8

Why is %d used to interpolate an integer into a format string? I don't recall seeing this done for any reason before. I hope Zed actually covers how dangerous format strings can be if not handled properly. Format strings are still (hilariously) one of the major exploitation vectors in C-based applications today. Edit: According to Wikipedia, %i and %d are synonymous. Sorry for the confusion.

d for decimal?

Re: Learn C The Hard Way

#16
post #9
post #4

I always had an idea of a 'for programmers' series of books for those who know how to program in one language (say, C++, Java or PHP) and wish to pick up a new language eg. 'python for programmers' would not need the first half of it dedicated to explaining strings, loops etc. and could get straight into it from a programmers perspective - a bit like K&R. You could then dedicate more content to explaining philosophy,…

Indeed, I currently get turned off by most books I pick up, simply because they start out on a too basic general level. If you however dig a little deeper you can usually find stuff that isn't too tutorialish. Like http://www.c-faq.com/top.html which has been an extremely solid resource for me.

I'm hoping to make this book ramp up faster than LPTHW, since I'm assuming people have either read that book or know one programming language already. However, I'm also a big proponent of practicing the syntax even if you think you're an expert already. It just makes things way easier later on.

Re: Learn C The Hard Way

#17
post #16
post #9

Earlier quoted context omitted.

Indeed, I currently get turned off by most books I pick up, simply because they start out on a too basic general level. If you however dig a little deeper you can usually find stuff that isn't too tutorialish. Like http://www.c-faq.com/top.html which has been an extremely solid resource for me.

I'm hoping to make this book ramp up faster than LPTHW, since I'm assuming people have either read that book or know one programming language already. However, I'm also a big proponent of practicing the syntax even if you think you're an expert already. It just makes things way easier later on.

how about 'if you are proficient at another language, feel free to skip to chapter x'? and put the generalized stuff at that point

Re: Learn C The Hard Way

#18
post #5

Do people really think C is some mysterious, inscrutable language? "To many programmers, this makes C scary and evil." Is this actually true for people? I find C code generally very easy and straightforward to understand; there's not any magic behind the scenes, like there is in any language that's more "high level" than C.

Yes, actually people are deathly afraid of C thanks to other language inventor's excellent marketing against it. There's a few things that you need to really nail to be good at C, and they're difficult things, but it's not "dangerous" like people keep claiming.

Re: Learn C The Hard Way

#19
post #10
post #3

I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

One of the first programs I tried to write in C++ (my first language) was a chess game. I eventually hacked it together, but it wasn't pretty.

The hardest part for me was learning the patterns necessary to do anything, and specifically to do it remotely well.

For example maybe one of the exercises could be some kind of board game, where you demonstrate how you translate "the ideas" into "the C code"? For example just because you know that a Knight can move two-plus-one spaces doesn't mean you have any idea where that code should be inserted into the program's structure, or how to write it in such a way where you avoid overrunning an array. (The naive solution would crash when the Knight tries to move off the board.)

Translating ideas -> C code was easily my hardest task when I was first starting out.

Re: Learn C The Hard Way

#20
post #10
post #3

I look forward to the content. As a beginning C++ instructor I find there is something lacking between the truth of the language and the conventions for presenting it. Nobody, AFAIK save for the truly hardcore student, has nailed it.

Got any feedback on the things students get wrong? My experience is they fail to grasp memory management, pointers, functions as pointers, linkers or just how a program actually runs. If you've got others I'd love to hear them.

dedicate some later chapters to ramping the reader onto assembler, the stack (and smashing it) and instructions

there are a lot of C devs who don't understand what it is their code is producing, and how an application and memory are managed

Post reply on HN