Hacker News new | ask | show | jobs
by greenyoda 4519 days ago
I'm not sure how malloc/free could be considered "advanced" C programming techniques. It's pretty hard to write any non-trivial program in C without using malloc/free and knowing the differences between static, stack-allocated and heap-allocated memory.
3 comments

You'd be surprised with how far you can get without dynamic memory or recursion...

Still, I agree with your general sentiment. That some of these are "advanced" topics is troubling. Too many programmers today don't know how a computer works. Our ideas of "mastery" are way too low.

in the modern climate of bootcamped rails hackers, knowing that memory even needs to be allocated at some point is advanced.
The challenging part is to get details of using them correctly and avoid security and portability issues and I consider it neccesaty introduction for section dealing with memory management.
And he didn't get all the details right.

    realloc(valid_pointer,0);
IS defined (in C89 no less) to act like free(). It is NOT operating system dependent.
True, but return type of free() is void, thus it says nothing about return value. The POSIX says: "If size is 0, either a null pointer or a unique pointer that can be successfully passed to free() shall be returned."
Depends on one's reference point. A lot of people in the web development world (for example) would probably consider manual memory management to be an advanced topic, because typically they've "grown up" with languages where memory management was so removed or abstracted as to be almost irrelevant beyond trivial "do I have enough RAM to hold this array?" type concerns.
Well honestly then they are sort of beginners to computer programming. Using malloc is not advanced C programming.