TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Some Were Meant for C (2017) [pdf]

116 pointsby chauhankiranabout 6 years ago

11 comments

aap_about 6 years ago
I don&#x27;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&#x27;t write any critical code so if I get hit by an occasional bug it&#x27;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&#x27;re done. This is perfectly fine but I feel like many people wouldn&#x27;t accept this kind of code because it&#x27;s not acceptable in other circumstances.<p>Anyway, the author makes a few good points that are important but often overlooked, but I don&#x27;t think I&#x27;d agree with him on the safety aspect in section 6. Making a safe C implementation doesn&#x27;t really appear possible. If you allow casting integers to pointers, how do you implement these saftey checks he&#x27;s talking about?
评论 #19746507 未加载
评论 #19746268 未加载
评论 #19746486 未加载
评论 #19746716 未加载
评论 #19748165 未加载
评论 #19747162 未加载
评论 #19747544 未加载
sevensorabout 6 years ago
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&#x27;t use C for everything, or even for many things, but I&#x27;m glad I know it and I&#x27;m glad it&#x27;s the substratum that holds most everything else together.<p>I&#x27;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&#x27;s all pretty sensible. (Excepting macro abuse, deliberate obfuscation, or gross incompetence.) It&#x27;s hard to say that about most any other language.
millstoneabout 6 years ago
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.
评论 #19745587 未加载
评论 #19745524 未加载
评论 #19746116 未加载
lone_haxx0rabout 6 years ago
If C didn&#x27;t have (as much) undefined behavior it would be practically perfect. There&#x27;s not much else that I would change about it.
评论 #19745824 未加载
评论 #19745801 未加载
MaysonLabout 6 years ago
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&#x27;s just like the reason human (and other mammals) have their optic nerve passing through the retina creating a blind spot: pure historical accident.
评论 #19746491 未加载
评论 #19746623 未加载
评论 #19745993 未加载
kosmaabout 6 years ago
Obligatory (and hilarious) read: &quot;The Night Watch&quot;[0] by James Mickens.<p>&gt; 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:&#x2F;&#x2F;www.usenix.org&#x2F;system&#x2F;files&#x2F;1311_05-08_mickens.pdf" rel="nofollow">https:&#x2F;&#x2F;www.usenix.org&#x2F;system&#x2F;files&#x2F;1311_05-08_mickens.pdf</a>
评论 #19747092 未加载
rocaabout 6 years ago
It&#x27;s dumb that in 2017 the author doesn&#x27;t say anything specific about Rust, which is by far the strongest &quot;C replacement&quot; candidate.<p>The author doesn&#x27;t deal with the problem that the &quot;direct access to memory without abstractions&quot; 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 &quot;dynamically checked C&quot; they propose as a solution to C&#x27;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&#x27;t seem to understand why they failed or have any insight into how to overcome the problems.
dangabout 6 years ago
Discussed at the time: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15179188" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15179188</a>
e9about 6 years ago
I would change it to: some were meant to c
评论 #19746066 未加载
评论 #19745460 未加载
morenoh149about 6 years ago
the other discussion mentions D as a better C.<p>Anyone ever try to build &quot;C the good parts&quot;?
评论 #19745335 未加载
danieltillettabout 6 years ago
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&#x27;s sometimes not the best choice.