5 ms·
idk man, C is catching a lot of hate lately, but I honestly don’t see why. C is a fine programming language, in fact, outside of maybe the lisp, logic programmi
by voidhorse 5y ago
idk man, C is catching a lot of hate lately, but I honestly don’t see why. C is a fine programming language, in fact, outside of maybe the lisp, logic programming, and concatenative language families, C pretty much is the only programming language. Every other language really just wants to be C while fixing a lot of problems that aren’t actual language problems but rather programmer problems. If we were all perfect human beings C is suitable for any task and would be flawless. But programmers make mistakes and often attempt to code in languages without actually understanding the language (a good example of this is not understanding memory models) and tons of modern features do not exist if you remove C as the motivating, negative factor they were a response to.
And sure, because of the way things shook out, programming languages have to speak C in order to do something useful as fast as possible, but if you carry this sort of argument to its logical ends, it amounts to the same thing as saying “I would love programming if only I didn’t have to compile to machine code” ASM has the same problems—architectures have different instruction sets. Or further, this is like complaining about the fact that you need to code against a particular fundamental design scheme like von neumann. This is just the nature of computing and different ideas and markets yielding different products.
Also this article makes a mistake of criticizing C on the grounds that it’s now a protocol and poorly designed as a protocol while simultaneously admitting that it wasn’t designed to be a protocol—so it seems a bit unfair to call these “bad design decisions” on those grounds. Furthermore, it’s a lot easier to make these sweeping criticisms than to effectively solve what is not only a massive technical but also social problem.
- na85 5y ago>a lot of problems that aren’t actual language problems but rather programmer problems This is a really naive take. In aerospace design we have the concept of "Design for Human Factors" or "Human Factors Engineering" which is basically an acceptance that the pilot or crewmember is a fallible, flawed "system". That is to say in aerospace we recognize that human beings have limits. They have finite breadths of attention, and they panic in a crisis, and they make mistakes when fatigued, and they're not capable of performing repeated tasks 100% consistently. That's why for example we make the "fuel cut off" switch a different size and color than the intercom switch. That's why we make the engine fire extinguisher handle very prominent and easy to grab, etc. For how many decades have software folks been writing use-after-frees and off-by-ones? When is Software as a field going to get over its collective hubris and admit that C is poorly designed from a Human Factors standpoint? A tool that requires unattainably- or unsustainably-high human performance is a shitty tool; get a better one.
- voidhorse 5y agoThat’s an enlightening counterpoint and I agree. I think, when common human factors are known and understood, we should design against them. I also would not recommend writing any large-scale modern software in C unless absolutely every piece of the codebase is performance critical, which is highly unlikely, and in which case you can probably use c++ for at least a few more safety features. Is C still a good choice for simple CLIs and small programs that don’t do anything drastic? I’d argue it is. I was moreso using hyperbole to try and point out that it’s easy to judge our forebears for problems that we didn’t even know were problems yet. Saying “C is a poorly designed language” usually amounts to saying “C is a poorly designed language from today’s perspective” which is a bit disingenuous considering we wouldn’t even know about these problems without C. It’s kind of hard to be omniscient and design against things you didn’t even know are problems yet. Furthermore, for all the flak it gets, I think C got a lot of things right—it’s easy to forget that programming languages copy more from C than they distance themselves from it—really the only major wins are giving programmers less control over memory, easier numeric types, easier string manipulation, and generics, and go proved that even the last enhancement isn’t really necessary. Sorry for playing the role of C apologist in this thread, but I feel a lot of these broad complaints about C are sort of immature insofar as they seem to eschew all historical context. I guess I’m just trying to point out that I see a lot more genius in C’s design than I see foolishness, but some people would have you think the C designers were complete idiots with the way they disparage the language. There’s a palpable lack of humility in such complaints.
- na85 5y ago>Saying “C is a poorly designed language” usually amounts to saying “C is a poorly designed language from today’s perspective” which is a bit disingenuous considering we wouldn’t even know about these problems without C. I mean okay, but whether or not we have historical perspective doesn't change the fact that as we now understand it, C is poorly designed. If it's poorly designed, then it's poorly designed and we should stop using it. There was a time when we "lacked historical perspective" and we built the De Havilland Comet, too. People died. Turns out that square windows cause stress concentrations so we started using better techniques. Nobody was arguing "yeah but for simple CLIs and small programs that don't do anything drastic, square windows are fine". Square windows suck so we make rounded corners now. C sucks, we should use something that sucks less.