I agree. I think the article is very right in identifying that C developers look at programming differently. I think that is a good thing. Even as a Die-Hard C programmer, I celebrate that people use other languages and especially that people are developing new languages like Rust, Odin, Zig and so on. I don't think it wrong for someone to reject C, if its not right for them. Do what works for you. I do think that given Cs massive success, people should perhaps be a bit more interested to figure out why, instead of just dismissing it so fast.
I greatly enjoyed reading.
Goes to show why it’s called “The C Religion”.
You get that in C as well in the form of libraries and frameworks. Today you saw a post in HN on how to do object oriented programming with C. Some time ago people shared C frameworks to enforce memory safety. There are generic data structures libraries for C as well.
I think your jab on how C programmers don't want abstractions, convenience, or cleverness is a weak strawman. It's obviously not it. What I think C programmers value is expressiveness and speed, and avoid bloat and overall inefficiencies, and C detractors don't want to address that because it forces them to face the real world tradeoffs which expose the shortcomings of their personal choices. There's a pervasive fear of missing out on the latest and greatest, and an irrational need to jump onto bandwagons, and C is extreme opposite of it. And yet it still outperforms anything that came after.
But then I discovered Usenet and the - I don't know exactly how to describe it - the cult of undefined behavior, and the people who care only about standards and not reality.
A basic, straightforward language like what people say C is, is certainly useful. I don't know Rust, and I don't have any plans to learn it.
As I think we all are aware, C originated before computers were standardized on 8 bit bytes, ASCII, Unicode, and 32/64 bit words. So, I mean, no matter how much people say it's appealing because it's simple and reflects the nature of the hardware, it really doesn't.
Is it not true that the Linux kernel is compiled with GNU extensions and not standard C?
I don't understand what you tried to say. The standard specifies how the language actually works, and therefore what developers can reliably do with it. How exactly do you see this as a break from reality?
It's hard for me to elaborate further without any idea of your background. How long have you been programming in C? Have you encountered TAOCP and MIX/MMIX? Do you write strictly standards compliant C? Did you use to read or post on comp.lang.c?
For reference, here is a list of things that are/were off topic:
https://benpfaff.org/writings/clc/off-topic.html
Dennis Ritchie posted on clc in 1999 and was told he was off topic. It has passed into history as a "joke".
"DECtapes are highly platform specific, and are not covered by ANSI C, which is the subject of this newsgroup (comp.lang.c). Try a DEC-related newsgroup.
If you want us to comment on your source code, please post it in the body of your email.
What was your C question?"
https://groups.google.com/g/alt.folklore.computers/c/wbzzoyS...
Since the mid 90s.
> Have you encountered TAOCP and MIX/MMIX?
I fail to see the relevance.
> Do you write strictly standards compliant C?
There is no such thing as non-strictly standards compliant C. It's either C, as specified by one of the international standards, or K&R C for those who can't target a standard, or things that are not C.
> Did you use to read or post on comp.lang.c?
Yes.
What was your point?
Then MMIX seems to me to sort of concede that sample code should be a little more like real life code, while still being far more difficult to follow than need be.
Some people just love complications for their own sake, like a medieval monk illuminating a manuscript. That's not wrong, but it's not right for everyone.
The issue I have is with people falsifying the reasons that C can be attractive. The IOCCC is the essence of what C is actually about. It is just not anything like an elegant "high level assembler" that reflects machine architecture. Maybe there is an alternative these days that fits the bill better, or maybe not.
>There is no such thing as non-strictly standards compliant C. It's either C, as specified by one of the international standards, or K&R C for those who can't target a standard, or things that are not C.
Well, here we go. First of all, the tone of this statement takes me back to clc. I could almost believe it's a direct quote.
Secondly, I haven't written a great deal of C code in the last 40 years, all told, but I was writing C code before C89 (and you, I infer, were not). It certainly wasn't K&R C, and it couldn't be standard C if that wasn't invented yet, right?
Everything meaningful "written in C", I think, falls into your category of "things that are not C". Like the Linux kernel.
That's just annoying to some people like it was when "kilobytes" were renamed "kibibytes" or "minor planets" were suddenly not "planets".
But shouldn't it bring with it a tiny bit of doubt that there might be something wrong with the ideals of the orthodox? There are many belief systems that have proved impossible for humans to follow, and just because many people are hypocrites doesn't mean that we should define ideals people strive for such that everyone becomes a hypocrite.
If people say undefined behavior allows your program to blow up the world, that is not debatable in isolation, as all definitions are arbitrary. But it is inconsistent with ever using or encouraging anyone else to ever use the language.
>What was your point?
I was pretty cautious. I think I read the FAQ as one was instructed to. I don't know if I ever posted any questions at all. I read it, and the arguments with newbies who over time increasingly seemed like trolls, as entertainment. Same as with the Ayn Rand worshipping Objectivists, the anarchists, or the Holocaust deniers in other groups.
I used to think, no matter how certain people are in their rectitude, can they not see it's leading to endless flamewars where people just wind them up for fun? What do they think the group is for? Do they make the connection that ultimately it is for whatever actually exists in that space? Do they really want what exists there?
There are ways to do all of these things, but they’re more manual, more error prone, and get in the way of doing the actual work you’re trying to do.
People complain about C++ that it can do much more. Yea. But there is no need to use template meta-programming, multiple inheritance and other special features. Actually I think programmers shouldn’t use them in productive code.
Recently some projects switched the compiler to ‘g++’ and use the basic subset of C++. Makes sense? Maybe Herb Sutters “C++2” will evolve, main features are safety and simplicity.
I’m fine with both C and C++. They do a good job. Address-Sanitizer is a game changer! But I want more.
> I would love to have some sort of “span” or “slice” primitive.
This was recently added!
> I would love language level tagged unions rather than writing them out each time.
There is std::variant, but it’s not as nice as a language provided solution, both to use and the generated code.
> Pattern matching isn’t exactly a type system feature, but relies on it to work, and would make those more useful.
This is not in C++, and my understanding is that the proposals are nowhere near close.
> The lack of destructors means a lot of manual handling of errors.
The huge C++ feature. Yes, a clear win. I think a version of RAII closer to Rust than to C++ would make more sense for C, though.
> The lack of generics makes it difficult to write generic data structures without losing type safety.
Yep, absolutely.
> There’s no real const.
There isn’t in C++ either.
The slice type you actually want has nice safety properties. The slice type proposed to WG21 about five years ago as std::span compromises a little bit, knowing they'd object to good engineering here, and it offers an unsafe way to access the slice as well as safe access. The committee voted to strip out safe access and specifically rejected efforts to ensure there was a sane way to use this type.
I assume Jarrad Waterloo's proposal to fix std::span in C++ 26 will get traction because it's now embarrassing for the project but there's no reason we should pretend this was some mere oversight. C++ is less safe than it should be on purpose.
Edit: I was looking it up just to make sure I remembered it correctly, and there’s been a recent change that makes it worse. The operator-> and operator* on std::optional are now marked noexcept, so implementations are forbidden from making the accessors safe.
It's struck me as being similar to operator* on Optional. I get why they did it. It makes sense. It's also unfortunate. I'm glad I'm not on that committee.
All these things are pretty tedious. And all these things are what other languages are doing under the hood. The difference is that C gives you a choice of _how_ to do (more) things; other languages do not.
Or, don't do polymorphism in C. It's not a mandatory technique. I love C, but I'd argue that if you're doing advanced OOP, you should use a more appropriate language.
Libraries can't specify these things in a compiler-enforced way either, so they remain "RTFM" problems for programmers to deal with manually.
There's really no excuse for C not having them, other than C being designed before algebraic types became mainstream. They make certain programming errors impossible, particularly with null values and misusing a union with the wrong type. It is possible to compile them as a zero-cost abstraction, and essentially all recent languages aimed at the same domain as C (Rust, D, Go, Zig, Hare, etc.) include them.
The what now?
C has a type system in the same sort of way that the United States has socialism.
I mean, the type system it isn't checking still isn't as strong or powerful as I'd like, but it is there. Unlike your CPU which doesn't care, C agrees that in principle an integer, a pointer and a floating point value are in fact different kinds of thing.
I think Option<!> is excellent, C thinks I should just write a comment in the program instead, these are big differences but they aren't so fundamental as the difference between US corporate welfare and socialism.
Sure, but that's kiddie-pool, 1970s-level stuff compared to modern type systems.
No business in their right minds is saying, in 2023, let's develop a new system in C. If they are, it's because they have people stuck decades in the past who are arguing for it.
(Edit: or, of course, they need to integrate with a C system, the number of which "is too damn high".
Very interesting. You cite these as drawbacks, and I consider them all to be advantages.
Which just proves the point!
> I suspect these preferences are irreconcilable.
I think you're right. Fortunately, they are only preferences and so aren't incredibly meaningful. I prefer C, but most of my professional work isn't in C. And I don't always choose C for any given project.
Every language has its own advantages and disadvantages, so I select the language for a project keeping in mind which one mesh best with the project at hand.
Why would they be advantages? Working more slowly and cautiously might be advantageous in some cases, but being forced to do so because otherwise your program might die a horrible death seems hard to justify as advantageous. Unless you're treating it as a sort of extreme sport, like rock climbing without a rope.
This culture of “fast coding” is a major reason software ends up so flawed. People are so enamored with quantity they completely forget quality along the way. And that means everyone suffers.
Besides, a strong type system also forces you to think about the design of your code, and demonstrably leads to more reliable results, on an industry-wide basis.
True. And so does using a language like C.
If you want to use it for hobby projects because you enjoy it, knock yourself out. But advocating its use for anything important hasn't been viable for decades except for legacy reasons.
It is! And there is absolutely a role for strongly typed languages.
> But advocating its use for anything important hasn't been viable for decades except for legacy reasons.
We entirely disagree here.
The big benefit of more stringent languages is that they require less effort on the part of the programmer to ensure safety and correctness. This is of great value -- perhaps even indispensable -- in certain contexts. For instance, if the programming team is large, or if the company wants to hire less experienced developers, or if the company wants to keep up a very high velocity.
But those are economic arguments. It's different than asserting that a given language is simple too dangerous to use under any circumstance. I think that assertion is entirely unsupportable.
The advantage is that it forces me to do the task properly, and prevents me from getting lazy and having important skills and habits atrophy.
Also, it doesn't feel like an extreme sport or anything. It's just programming, like in any other language. Not any more or less stressful.
The "just trust me bro" school of programming is not suitable for delivering serious systems.
Only if you're writing bad programs. The idea that it's impossible to write good, solid programs in any given language is ridiculous.
> The "just trust me bro" school of programming is not suitable for delivering serious systems.
No one is advocating that. Your choice of language doesn't change the need for processes that ensure quality.
The data disagrees. There's plenty of evidence that the severity of bugs and the number and severity of security bugs is far higher in languages like C or C++ than in memory-safe languages.
> Only if you're writing bad programs.
This is precisely the "just trust me bro" mentality I was referring to.
"I write good programs, I swear!"
But you're human, and you really don't. You make mistakes. Empirically, you make roughly as many mistakes per line as programmers in other languages, but the consequences of those mistakes are worse.
You can argue with me all you want, but you're essentially arguing with reality. C has survived for legacy reasons, but almost everyone is desperate for a better, more robust alternative.
Just so you know where I'm coming from - I learned C in the early 80s, not long after learning Fortran. I later started using C++ because it seemed to offer some benefits. But now - more than forty years later, when there are so many better alternatives for any given problem except one which requires legacy integration - it's astonishing to me that people are still staunchly defending C.
It reminds me of what Max Planck said about physics:
> “A new scientific truth does not triumph by convincing its opponents and making them see the light, but rather because its opponents die, and a new generation grows up that is familiar with it.”
I think that should be a good thing.
I doubt you crafted the HTTP call to post this comment by hand, even if you could. I could. I don't want to. That's why tools exist.
In the same way, C imposes an extra burden compared to other languages. If I declare a std::vector in C++, or a Vec in Rust, it will be deallocated when the scope is exited. But in C, every malloc() requires a call to free(). It requires extra effort for no benefit.
I prefer a world where people actually think about the resources they're using.
I don't see how having to remember to always add in calls to free, with the cost of using more memory if you forget to do so, is really supposed to help you minimize your memory usage. That's the main difference we're talking about here...
Will destroying this window free the memory for this font instance? Will destroying this DOCX processing object close the file? Who knows?
But when the rule is just to clean up after yourself, it's a lot easier to remember.
There is a benefit, although it may not be useful for your use case. In that situation, I agree with you -- use a different language.
I find it interesting that so many comments here criticizing C (and a couple of other languages) seem to be taking the stance that "if it isn't good for every kind of task, it isn't good for any kind of task".
Every language both rocks and sucks, depending on what you're doing with it. There is no One Ring to Rule Them All. That's why we have so many different languages -- we should be choosing the one that fits the job at hand.
This is why I think holy wars over languages are always ridiculous. Any given language may be a terrible choice for a particular job. That's not a fault of the language, it's just a sign that language is the wrong tool. Use a different tool.
I suppose another piece of evidence about how this is a personality thing is that I hate having to learn specialty tools. They're limiting in that typically, they only exist on certain platforms, and they often specific to certain languages, so knowing those tools often doesn't help me generally. (Libraries and the equivalent count as tools here, too.)
So I make it a point to not grow a dependency on them even when I use them. I very much prefer to focus on skills that I can leverage widely.
> gets out of your hair and lets you ge on with programming
This is the divergence, I think. For me, the method in which c “gets out of my hair” means that more burden is placed on me, the developer. Which means I have to work more slowly, cautiously, and remember things that a good type system could have been checking for me. And the lack of features means I spend time working around that lack rather than getting real work done.
I suspect these preferences are irreconcilable.