Live data from Hacker News

What do you want to see in Learn C The Hard Way?

news.ycombinator.com

71–80 of 127 posts

Re: What do you want to see in Learn C The Hard Way?

#73
post #21

whatever you do, make your examples bulletproof. even if it's not how you would normally write the code and it seems overly cautious, do your audience a favor and write the example that way anyway. if there are any buffer overflows, integer overflows, off-by-one's, signedness issues, failure to check return values of everything, use of typically insecure things like sprintf instead of snprintf, all of these problems…

Or as a compromise, start with simple, easy-to-read examples teaching basic principles. Give them datasets that will cause the program to blow up, and then explore both the causes and solutions to failure. Ideally, work back from the failures and encourage the reader to try out solutions that don't work so as to develop rigorous problem-solving skills.

I've always felt that teaching 'don't do that, cause it's bad' sticks rather poorly - unless something that obviously dangerous is involved, making your own mistakes is much more educational than memorizing a set of best practices and never even peeking into those blind alleys or pitfalls. You can do that and have good habits, but you'll have a dogmatic rather than a fundamental grasp of the knowledge, and this will constrict further development.

Re: What do you want to see in Learn C The Hard Way?

#74
post #3
post #2

One important thing I would like to see in such a book is one or more chapters devoted to memory management best practices.

100% agreed, I see way too many people struggling with realloc/calloc in ##C, let along comprehending heap fragmentation.

A good solution for this would be to make one of the exercises to be building your own heap allocator.

Re: What do you want to see in Learn C The Hard Way?

#75
I'm not sure it makes sense any more to teach C to beginners -- by the time someone has a need to write C code, they really ought to have mastered programming in another language or three, first.

Personally, I think a teaching/review ladder would be as or more helpful than a tutorial text. Getting good at C, at least from my current starting point, seems to mostly be a matter of discipline and practice.

I'm thinking of something like this: http://gtl.xmp.net/

Along those lines ;) I'll probably be releasing code from my first medium-sized C project in a week or so... anyone care to offer tips on how to get more experienced eyeballs on it?

Re: What do you want to see in Learn C The Hard Way?

#76
post #54
post #11

Other than K&R (which everyone knows about), what is the current CW on best C books?

C Interfaces and Implementations is really good: http://www.amazon.com/Interfaces-Implementations-Techniques-...

Different books work for different folks, and lots of people seem to love this one. I however love C and found this book to be an abomination. K&R is brilliant. Given an opportunity, I would eradicate this book from the face of the earth lamenting only the damage it has already done.

Examples provided here: http://news.ycombinator.com/item?id=1705332

Re: What do you want to see in Learn C The Hard Way?

#77
post #21

whatever you do, make your examples bulletproof. even if it's not how you would normally write the code and it seems overly cautious, do your audience a favor and write the example that way anyway. if there are any buffer overflows, integer overflows, off-by-one's, signedness issues, failure to check return values of everything, use of typically insecure things like sprintf instead of snprintf, all of these problems…

Or as a compromise, start with simple, easy-to-read examples teaching basic principles. Give them datasets that will cause the program to blow up, and then explore both the causes and solutions to failure. Ideally, work back from the failures and encourage the reader to try out solutions that don't work so as to develop rigorous problem-solving skills. I've always felt that teaching 'don't do that, cause it's bad' st…

You've more or less described what I plan to do and why.

Re: What do you want to see in Learn C The Hard Way?

#80

Teach how to implement a couple of data structures more complex than linked list and binary trees (maybe hash table). Teach how to implement a couple of non-trivial algorithms (e.g., quicksort, topological sort).

The how isn't much use without the why.

Planned on it.

Post reply on HN