Hacker News new | ask | show | jobs
by mywittyname 2954 days ago
I'll throw out my $0.02, which is C is a terrible language to learn. Much of writing "good" C revolves around knowing all the pitfalls to check for, then dealing with the archaic error handling mechanisms. Tomes have been written on the subject of proper error handing in C.

> fundamentals of things like memory allocation, data types, call stacks, etc. remain a mystery to them.

I don't think C is especially good at teaching these.

Unless you roll your own malloc, the big difference in memory allocation in C vs. say, Java is that C requires the programmer free memory after allocation on the heap. This is more tedious than difficult.

Data types exist in other languages. You can unpack raw bytes of data using Java and simulate the behavior or unions.

You'll have to explain how call stacks are more exposed in C. Best I can think is calling conventions, but that's more the domain of compilers than language. Buffer overflow prevention, maybe (but again, I think that's more tedium to deal with).

C is great because it's a small language. But I don't think it's an especially educational language.

1 comments

Yeah I just disagree. I actually think Java is a terrible teaching language. Folks for whom Java is the closest they come to the hardware tend not to understand the internals of how computers actually work well enough to do things like understand where bits fit into bytes or what happens if you recast an int into a double without converting the underlying data.

Many times that doesn't matter, but to me it's important to have a supple and complete understanding of the underlying ideas. Java fails at that.

When I referred to memory I meant more than malloc and free. It's things like understanding how an array of ints is laid out in memory and what happens when you treat it as an array of chars instead. If you talk about this to a Java programmer, their eyes are likely to cross.

Your argument seems more in the vein of "C programmers are smarter java programmers" while ignoring the actual discussion, which is C is not a good teaching language. Yeah, you'll learn some stuff by virtue of blindly running over the language's landmines. I don't consider trial by fire to be a great way to learn.

> It's things like understanding how an array of ints is laid out in memory and what happens when you treat it as an array of chars instead.

This is one of said landmines, as the size of both is architecture/compiler specific. The only thing you learn by stepping on this one is, "use fixed-width integers when you care about exactly how many bytes the value is."