I don't like how people on the internet hate on C all the time. To me C is a wonderfully simple and elegant language that I can most of the time very clearly express my thoughts in. I find that this not the case with many other languages. This is the reason I use C. Of course compiler writers are trying to sabotage this but I don't write any critical code so if I get hit by an occasional bug it's not a big problem.
I think C is misunderstood, perhaps because it is used everywhere and standards for critical pieces of software are applied to non-critical ones.
E.g. never freeing memory, even leaking it by destroying all references to it, can be totally fine if your program just runs for a few seconds. Just allocate what you need, throw it away, and let the OS clean up when you're done. This is perfectly fine but I feel like many people wouldn't accept this kind of code because it's not acceptable in other circumstances.<p>Anyway, the author makes a few good points that are important but often overlooked, but I don't think I'd agree with him on the safety aspect in section 6. Making a safe C implementation doesn't really appear possible. If you allow casting integers to pointers, how do you implement these saftey checks he's talking about?
I will always have a soft spot for C. It was my first language. I wrote my first linked list in C. 30 seconds later I had my first segfault. C was the entrance to the rabbit hole for me. I went down through assembly language, down through logic design, circuit design, and transistor theory, all the way down to fabrication and quantum mechanics. It was a long time before I came back from that trip. Today, I wouldn't use C for everything, or even for many things, but I'm glad I know it and I'm glad it's the substratum that holds most everything else together.<p>I'm glad because C is an idea you can hold in your head. I can look at old C, I can look at new C, and it's all pretty sensible. (Excepting macro abuse, deliberate obfuscation, or gross incompetence.) It's hard to say that about most any other language.
What is lovely about C is its paper-thin layer atop the syscall pokey bits: signal, vfork, mmap, etc. No surprise that other languages either start by using libc, or find their way there eventually.
The only reason C is as popular as it is is that it was used to write Unix, which was widely distributed and implemented. The rest is just following on that. It's just like the reason human (and other mammals) have their optic nerve passing through the retina creating a blind spot: pure historical accident.
Obligatory (and hilarious) read: "The Night Watch"[0] by James Mickens.<p>> You might ask, “Why would someone write code in a grotesque language that exposes raw memory addresses? Why not use a modern language with garbage collection and functional programming and free massages after lunch?” Here’s the answer: Pointers are real. They’re what the hardware understands. Somebody has to deal with them. You can’t just place a LISP book on top of an x86 chip and hope that the hardware learns about lambda calculus by osmosis.<p>[0]<a href="https://www.usenix.org/system/files/1311_05-08_mickens.pdf" rel="nofollow">https://www.usenix.org/system/files/1311_05-08_mickens.pdf</a>
It's dumb that in 2017 the author doesn't say anything specific about Rust, which is by far the strongest "C replacement" candidate.<p>The author doesn't deal with the problem that the "direct access to memory without abstractions" style they love so very easily drifts into undefined behaviour. It also optimizes very poorly due to lack of aliasing information, unless you enable type-based alias analysis in which case accidental undefined behavior is catastrophic.<p>The "dynamically checked C" they propose as a solution to C's safety issues is no solution at all until you can get it to work in practice. A lot of really great people, including the researchers he cites, have tried really hard to make it work and have failed in practice. He doesn't seem to understand why they failed or have any insight into how to overcome the problems.
Discussed at the time: <a href="https://news.ycombinator.com/item?id=15179188" rel="nofollow">https://news.ycombinator.com/item?id=15179188</a>
The best thing about C (apart from speed) is that for every issue with the language there is a tool that fixes the problem. It can do everything everywhere even if it's sometimes not the best choice.