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 articleThe 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.
Related
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
I Hope Rust Does Not Oxidize Everything
The author expresses concerns about Rust's widespread adoption in programming, citing issues with syntax, async features, complexity, and long compile times. They advocate for language diversity to prevent monoculture, contrasting Rust with their language Yao.
Defense of Lisp Macros
The article highlights challenges in automotive software development, emphasizing reliance on C, fragmentation from specialized tools, and advocates for powerful languages like Lisp to improve efficiency and integration.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.
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 ?
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”.
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.
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.
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.
>You don’t see England trying to improve itself, do you?
This felt unnecessary.
...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
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!
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.
... it's "the" programming language.
</smug>
Related
Weekend projects: getting silly with C
The C programming language's simplicity and expressiveness, despite quirks, influence other languages. Unconventional code structures showcase creativity and flexibility, promoting unique coding practices. Subscription for related content is encouraged.
I Probably Hate Writing Code in Your Favorite Language
The author critiques popular programming languages like Python and Java, favoring Elixir and Haskell for immutability and functional programming benefits. They emphasize personal language preferences for hobby projects, not sparking conflict.
I Hope Rust Does Not Oxidize Everything
The author expresses concerns about Rust's widespread adoption in programming, citing issues with syntax, async features, complexity, and long compile times. They advocate for language diversity to prevent monoculture, contrasting Rust with their language Yao.
Defense of Lisp Macros
The article highlights challenges in automotive software development, emphasizing reliance on C, fragmentation from specialized tools, and advocates for powerful languages like Lisp to improve efficiency and integration.
Objective-C is like Jimi Hendrix (2014)
The author compares Jimi Hendrix's influence on guitar music to Objective-C's impact on programming, noting how perceptions of its features have evolved as newer languages emerged, reflecting on programming history.