Hacker News new | ask | show | jobs
by vngzs 1827 days ago
I'm fairly conflicted about this. While I believe that learning C teaches bad habits - manual memory management tends to account for some absurd percentage (70-80%) of CVEs in modern programs - it's also unquestionably tethered to the history of software, and a majority of the immense foundation of tooling on a Linux system is authored in C.

There is a terrific benefit to learning on a platform where you can not only look up documentation within the system (man pages), but also "dig deep" into the code of any particular piece of the system you are interested in. So in learning C, you gain access to the body of knowledge contained in a Linux system, or contained in a BSD, and when you get curious about something like "These loops and conditionals are all fine and well, but how does a window actually get drawn to my screen?" you have everything at your fingertips to go and answer it.

Is that connection to the machine possible without learning C? You could use a toy operating system written in something else, but you miss out on the honesty that comes from teaching the same system that people are actually using (or at least able to use).

I think Go might not be an unreasonable alternative. It shares C's philosophical heritage, removes the need for manual memory management, and is capable of exposing a student to pointers, creating images, and HTTP communication all within the stdlib and the first chapter of the official book. The only downside, as I see it, is that one would need to additionally learn something like Rust to be able to apply the concepts to things like kernel drivers and close-to-the-metal programming.

2 comments

Go sounds like the worse of both worlds from a teaching point of view: too high level if you want to understand what the machine is doing; but inheriting almost all of C's bad ideas that the GP was complaining about (except for manual memory management).
> learning C teaches bad habits - manual memory management tends to account for some absurd percentage (70-80%) of CVEs in modern programs

this is a garbled thought. The average person may have trouble with manual memory management, and C requires some manual memory management (the stack is automatic), but that's not C teaching bad habits.

You can learn to do manual memory management in C, because C teaches manual memory management.

that doesn't make manual memory management a good idea for the average programmer, but that's not C's fault.

experience with C teaches good manual memory management in the same way that working with sharp knives teaches good knife management. Do professional people get cut with sharp knives? yes. Are sharp knives a good idea? yes. All the time for everybody!? nope