August 2nd, 2024

C Isn't a Programming Language Anymore (2022)

The article examines the shift in perception of C from a programming language to a protocol, highlighting challenges it poses for interoperability with modern languages like Rust and Swift.

Read original articleLink Icon
C Isn't a Programming Language Anymore (2022)

The article discusses the evolving perception of the C programming language, arguing that it has transitioned from being a programming language to a protocol that other languages must adhere to for interoperability. The authors express frustration with C's Application Binary Interfaces (ABIs) and the challenges they pose for modern programming languages like Rust and Swift. They highlight that C's ill-defined nature complicates the process of creating Foreign Function Interfaces (FFIs), which are essential for new languages to interact with operating systems and existing libraries. The article emphasizes that every new language must learn to "speak" C to function effectively, leading to a situation where C's inconsistencies and ambiguities become a barrier for developers.

The authors point out that parsing C headers is nearly impossible due to the complexity of C's type system and the lack of a standardized ABI. They illustrate this with examples of discrepancies between major C compilers, which can lead to failures in interoperability. The article concludes that many languages have resorted to hardcoding type definitions to bypass the complications introduced by C, indicating a significant shift in how programming languages are developed and interact with one another. This situation raises concerns about the future of programming languages and the dominance of C as a de facto standard, despite its inherent flaws.

Link Icon 21 comments
By @JackSlateur - 4 months
Bah

I read until the "FFI" section

Yes, you must use "C" if you use the libc (seems obvious)

However, you can issue your syscalls directly. Of course, to do that, you will have to rewrite your own libc .. nothing is free.

It shall be noted, however, that this is not possible in every environments: I believe that openbsd's code must use the system libc. At the same time, on windows, you must use the provided library. This does not mean the OS library is always C (but this means your new language must do FFI with whatever language is used by the system).

Maybe only Linux allows anybody to issue syscalls directly ?

By @MuffinCups - 4 months
C is the thin wrapper of people talk around machine talk. It's the primary interface between man and microprocessor. FFI is a pretty good convention for giving your latest, redundant, unnecessary, vanity language the capability talk to the OS which is almost universally written in C.
By @wruza - 4 months
Emotions aside, what is the solution?

You have platforms with different [efficient] ways to pass arguments, operating systems and firmware with different conventions, and on top of that there are different compilers that will inevitably differ in fringe areas. All of this must be supported in a binary form.

What is the answer and why C’s answer is more problematic than any other? TFA reads like a misdirected blame or venting on “legacy”.

By @ksp-atlas - 4 months
What Zig has done is actually build their own LibC equivalent from scratch so they don't have to deal with interfacing with that, but they also have famously good C compatibility good enough that you can just import a library almost like it's C and use it
By @somelamer567 - 4 months
I'd say the author's mental model of the nature of C as a programming language isn't accurate, not helped by efforts to standardise the language.

It could be argued that C is little more of a defined programming language any more than assembly languages is. It's worth remembering that C was invented in part, to abstract away architectural differences, so that Unix could be ported to new platforms.

If you want 'standard' with a sane well-defined ABI that never changes, there are better choices in 2024.

By @beardyw - 4 months
People just live in bubbles don't they. If I want to write a 100 line program for a tiny microcontroller what should I do? Write it in assembler? I mean I could, but I think the author would have even more esoteric problems with that! Meanwhile I would just get the job done with a language that apparently doesn't exist anymore.
By @znpy - 4 months
Shortsighted discussion.

C’s integers being wobbly-sized is the reason we have C compilers for pretty much every conceivable cpu architecture and we only have rust/swift/other compilers for a handful of carefully picked architecture.

There are entire industries where C-as-a-protocol is fine enough (and actually appreciated, even though the author doesn't like it).

There are entire industries that do not use X86 or ARM, let alone RISC-V. There are many use-cases for MIPS, weird/other architectures (PowerPC, 8051, m68k-derivatives, pic-micro)... I had a relative that used to work on control software for space stuff, the CPUs used there are even older and definitely not x86/x86-64, arm or risc-v).

So yeah, complaining that the C language does not fit your own very specific use case is very shortsighted.

We should all remember that the world does not revolve around us and around our own use case.

By @sys_64738 - 4 months
Why do people post under such stupid headlines as it gives the author zero credibility.
By @camgunz - 4 months
By @deterministic - 4 months
Not true. At work we maintain 1 million+ line C/C++ applications and libraries that run large international companies all around the world. And we hire C/C++ developers all the time.
By @exe34 - 4 months
while I don't particularly mind C myself, I have on occasion passed messages between processes over nanomsg to avoid merging the incompatible contents of two conda environments.

I wonder if more platforms would consider having a stub that connects with the OS and talks to the rest of its kin via sockets of one sort or another. it does introduce a ton of lag and multiple kernel-userspace jumps I suppose.

By @NeoTar - 4 months
>Sorry C, you conquered the world, maybe you don’t get to have nice things anymore.

>You don’t see England trying to improve itself, do you?

This felt unnecessary.

By @rob74 - 4 months
(2022)

...wouldn't have mentioned it if I hadn't started reading and then remembered that I had already read it some time ago. Might have been https://news.ycombinator.com/item?id=33509223

By @mediumsmart - 4 months
Even I know that C is still a programming language. But to be sure I asked the Oracle :

can I write a c program and compile it on macos?

Yes, you can write and compile C programs on macOS using a compiler like `clang` or `gcc`.

I have both - I made a file hellodude.c what small program can I write there to test this?

#include <stdio.h>

int main() { printf("Hello, dude!\n"); return 0; }

I did that - how do I compile this?

clang -o hellodude hellodude.c

it works thank you

You're welcome!

By @gumby - 4 months
Oh boo hoo. Yes, C really sucks, but it exports a crummy and limited abstract machine which is fundamentally a PDP-11. The author might just as well complain, in fact would better complain, that interfacing to machine code is painful.

Just suck it up and put the OS interface (with the appropriate paradigms and affordances for your language) into your language’s standard runtime. That’s part of the work of writing a language.

Whatever model you think should replace it will inevitably only be useful for some languages and as bad as a C interface (or worse) for others. The iAPX 432 was a notorious example — in hardware! Lispms, sadly, were another.

It is irksome that some will consider C the “lowest common denominator”. It ain’t. It’s just a shitty, path-dependent valley in the possibility space. And as for shitty, well, I use the toilet every day, and it’s not the high point of my day, but it’s where we ended up (so far) as part of the mechanism by which we power our bodies and also get to enjoy yummies. No point I’m complaining about it, it simply is what it is.

By @tpoacher - 4 months
It's not "a" programmimg language ...

... it's "the" programming language.

</smug>