Live data from Hacker News

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

news.ycombinator.com

61–70 of 127 posts

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

#61
I understood K&R years ago, but somehow I feel completely inadequate to being a C programmer. I think there is some kind of black art involved in memory management. I checked recently and it seems K&R doesn't even talk much about memory management.

I just wish to learn the current state of the art - what are best practices that have evolved since K&R?

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

#62

Reading through Zed's tutorial reminded me of some Pascal and C tutorials I downloaded in the old BBS days. They were a great introduction to both languages when I was just learning to program. I just had a look on simtel but I couldn't find them. Maybe you should put some effort into scanning old software archives and seeing if you can unearth them. C is pretty old - you wouldn't be the first one that had this idea.

I'll be referencing a lot of material, not all of them programming related. I'll try to dig up some old text files I liked as a kid per your recommendation.

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

#63

Earlier quoted context omitted.

I don't think the learner would appreciate the subtleties, and I don't agree that they'll learn anything from it. I can reinforce each lesson/problem you're describing one by one through the exercises, but a new person simply wouldn't know good code if it slapped them in the face. Confer with Learn Python the Hard Way to get a feel for the aesthetic and technique I'm working towards. I don't want to write bulletproof…

> I don't want to write bulletproof code, I want to teach them how and why to write bulletproof code. This confuses me. How can you teach someone to do something if you won't do it yourself? Reading your statement literally, you are effectively going to say, "This is how and why to write bulletproof code, but I'm not going to." The whole point of LxTHW is to learn by doing. If you're doing it wrong, they're learning…

Nobody's qualified to run a company when they do their first startup either.

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

#64
post #61

I understood K&R years ago, but somehow I feel completely inadequate to being a C programmer. I think there is some kind of black art involved in memory management. I checked recently and it seems K&R doesn't even talk much about memory management. I just wish to learn the current state of the art - what are best practices that have evolved since K&R?

That feeling of inadequacy and incompleteness post-K&R is something I experienced too and is something I'm hoping to address.

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

#65
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…

I don't think the learner would appreciate the subtleties, and I don't agree that they'll learn anything from it. I can reinforce each lesson/problem you're describing one by one through the exercises, but a new person simply wouldn't know good code if it slapped them in the face. Confer with Learn Python the Hard Way to get a feel for the aesthetic and technique I'm working towards. I don't want to write bulletproof…

If you're not qualified to meet that standard then don't write a C book (or learn more before you do). C programs are either bulletproof or they are a hazard.

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

#67
post #22

What I really miss is some C book that teaches the modern approach to "object-oriented" C (as done in Gtk, Apache, CPython etc.). Actually many programmers (presumably with only passing knowledge of C programming) even actively proclaim that you cannot program in C in this style.

I'll teach function pointers, and might expose them to some style of OO C, but I haven't made any decisions on it. My approach is going to be relatively unflavored by the Macro Hell of other projects. I'd rather not instill those habits. They can learn that on their own time. I want the learner prepared to write clean sysprog code. That's it, the rest they can learn having been taught proper C and make their own styl…

Well, function pointers are only one aspect of this. Suprisingly many experienced C programmers I've met don't know that you can safely cast pointer to struct to pointer to it's first field, which is pretty important trick to achieve reasonable OO (with real inheritance) in C.

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

#68
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…

On the other hand, not all C code have to be secure. If I'm building a game for the Wii, don't bother me with stack overflows. The same goes for all the simulations out there (C is used about as much as Fortran in research). That's a lot of code.

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

#69

Earlier quoted context omitted.

> I don't want to write bulletproof code, I want to teach them how and why to write bulletproof code. This confuses me. How can you teach someone to do something if you won't do it yourself? Reading your statement literally, you are effectively going to say, "This is how and why to write bulletproof code, but I'm not going to." The whole point of LxTHW is to learn by doing. If you're doing it wrong, they're learning…

Nobody's qualified to run a company when they do their first startup either.

That's a pretty dishonest analogy. Your first startup will succeed or fail based on its merits. If you write a book for beginners that is inaccurate, those inaccuracies will be spread in spite of their lack of merit.

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

#70
Just because you're working in C doesn't mean you need to handle every detail yourself. In fact, please don't handle every detail yourself. Show your readers how to use some of the great libraries C has to offer. Not just system-level abstraction layers, either.

You need to go get libraries for a lot of the stuff you'd normally use the standard library for in a more modern language. These libraries exist, and many of them are excellent, but because they're not built-in, people are less likely to use them. This is especially dangerous in C, because it requires so much work to do anything even vaguely complex.

edit: That came off as saying "Teach some libraries". What I really mean is "Teach people to go find libraries."

Post reply on HN