by fjfaase · 3y ago · 0 comments
The speaker discourages C for new projects, but that says more about the problem domains they work in than C itself. C is what it is because the hardware and assembly language are what they are. Folks who want a safer C should design a new hardware architecture with a "safe" assembly language and a new low-level language that targets it.
It's a massive red flag that they don't know enough to be useful.
C is great for the things C is great for, however small that range may or may not be now and in the future.
Any other stance is reductive and misleading.
I’ve been writing C since 1991 and I can’t think of anything where I wouldn’t start a new project in some other language. There are many interesting choices of varying maturity in the low-level systems programming space: Zig, Rust, Crystal, D, Swift (if the standard library ever gains support for system-level programming). Even the “better C” subset of C++ will allow you to avoid certain classes of security bugs completely.
I don’t think C is even merely adequate for anything at this point; defaulting to memory safety is table stakes in any domain where C was once dominant.
Rust is exciting and proving itself about as rapidly as such a language could be expected to do. But there are big questions around how all of this plays out in a long-lived project. There's a good argument that C's simplicity is an asset here.
I like Rust a lot and have done some cool stuff with it. I believe the challenges of long-lived projects will be solved. But at the same time, I admit that there are a lot of other factors (including non-trchnical ones). If you pick a language that doesn't last for whatever reason, and you have a couple decades worth of code, the options are grim.
Implementing low-level code that is important enough to prove correct, without going through the additional effort of de novo proving your entire toolchain is correct.
If I use a micro controller to control a string of leds I do not care about security/memory safety. But I do care about being as close to the metal as possible, and being able to understand the compiled code.
There.
Writing readable code. I'm a huge fan of Zig and Rust too but at the end of the day they just aren't C.
It's really not, though. What C is an abstraction of is computer architecture as it existed by the late 1960s.
I don't follow. Barring micro-code, hardware is designed for executing either RISC or CISC instructions. If anything, the industry has matured and we see less esoteric ISA's today than in the 1960s.
Would that be LLVM's IR or MLIR (https://mlir.llvm.org)?
It's almost the exact opposite extreme on the pendulum, where C allowed anything while Rust limits to only what the language designers conceive as proper and not just safe.
Zig can gain memory management systems like Nim's ARC which works well for system design and adds temporal safety. On the other hand Rust's trait system likely will never become an "open ended" type system like say Julia's. Heck, even overloaded function types don't seem likely in Rust.
Rust does not have a defined standard yet, but I suspect it also would be quite large.
- Swift has plans to incorporate temporal safety in upcoming releases. - Zig isn’t fully baked yet.
Rust will be king of that space for a while, though.
I assume you're being facetious with the "recently came across", since scipy is so common, but I will add that nearly every math-intense library is a clever wrapper for some Fortran code.
I would be perfectly happy to see many hardened C libraries become the foundation of the next gen systems/ embedded languages. It does bother me slightly when we abandon the past entirely and attempt to "rewrite it in X"
But just like Fortran is still used for nearly every math-intense library, mostly invisible for most of the users, I suspect that C will still be around in 50 years from now.
I agree, with his observation that C should be no longer your language of choice for new projects. I personally still prefer using C/C++ for my private software projects, simply because it is the language I am most fluent in. This year I used it for AoC.
Not exclusively in C, not anymore: https://docs.kernel.org/rust/index.html
It might take another decade for a C-free build to be possible, though.
AFAIK Torvalds has also stipulated that any Rust code needs to be mirrored in C.
Do you have a cite for this? I hadn't heard this at all.
Rewriting that amount of code in ten years sounds very very hard, at least.
A potential strategy would be to set a date where any new drivers must be written in Rust. Deprecate every non-Rust driver on a date after that. Focus on rewriting only the drivers necessary for current hardware platforms (and some sensible/arbitrary cut-off going back x years). Then set a final deadline for a New Linux kernel release that removes all deprecated/C drivers.
I would blindly estimate that entire process to take 10-20 years (not including the time needed for debating the whole thing).
Then somebody "just" needs to rewrite the rest of the code.
So, uh, any volunteers?
Now, rewriting everything, including all the legacy drivers? Yeah, never happening even if Rust succeeds utterly.
I wish something like it could happen, but I am causyiously optimistic.
https://github.com/bjorn3/rustc_codegen_cranelift
The compiler frontend is already written in Rust.
SciPy is a highly optimized library and Fortran is faster than C for some tasks:
Unfortunately it's an industry with a lot of stubborn old people so I don't see any major changes happening until they've retired but I'm willing to bet that async is going to revolutionize embedded development. Being able to await interrupts and doing efficient cooperative scheduling while writing straight forward code is a massive QoL improvement which is what embassy is enabling: https://embassy.dev/
Unfortunately Ada is held back by a genuine lack of awareness and some old misinformation baggage.
People normally think that C is the best for low level embedded programing, but from my experience, it pales in comparison to the amount of low level control and type safety that Ada provides, even when you restrict yourself to a small subset of the language (note: Ada is often used on barebone systems and without an Ada runtime). Given the interoperability Ada has with C, it means you don't have to rewrite everything in order to incorporate it into existing code bases.
It's a good thing more people are realizing we really need to stop settling for C and C++, stop investing more money into tools that simply compensate for the weak foundation of those languages, and finally adopt safer alternatives.
There are surelly other factors that weight in using C, but not for lack of options (in many cases).
Or maybe they will, given how much consultants in those languages happen to be paid, as no one else wants to touch them.
I do dream about that. Just being able to tag along while some programmers learn their Xth framework as a language.
Maybe someday I might concede and move on from C89 to C99.
I don't think there is any reason to choose C89 over C11 other than fear of new compiler bugs and compatibility with old compilers?
That's an extraordinary claim indeed; if people outside tech were going to call bullshit on EULAs as a liability shield, they would've done so in the last 50 years of software sales.
Reliability or the lack thereof has never been an impediment to some piece of software getting popular, but to me, you appear to believe that people want more reliability from software than they have been getting thus far.
Your belief is at odds with reality.
- Return of goods in digital stores
- Warranties in consulting projects, requiring free of charge fixes up to one year
- Cybersecurity bills
It will only get better from now onwards.
If anything, C may still be going strong for another 20 to 30 years.
One reason for C to disappear completely would be if computer architectures would change so much that current programming languages no longer even map to those new architectures (e.g. all the existing programming languages would need to be dumped anyway).
> The Lindy effect (also known as Lindy's Law[1]) is a theorized phenomenon by which the future life expectancy of some non-perishable things, like a technology or an idea, is proportional to their current age. Thus, the Lindy effect proposes the longer a period something has survived to exist or be used in the present, the longer its remaining life expectancy.
C does have a similar kind of niche at first glance: systems programming is of course conservative, rewriting everything is unlikely, and of course, C is the language used for ABI. Except on closer inspection, that moat is remarkably shallow. Being the language of ABI means that every competitor language has some way to speak C guaranteed, so the friction of rewriting systems software Ship-of-Theseus-style is much lower (though still nonzero). Systems software is rewritten from scratch on a much higher cadence: in the last 20 years or so, most of the userspace system glue for Linux has been replaced (e.g., systemd, iproute2, pulseaudio, wayland). And we've learned over the past few decades that there's no practical way to fix C's fundamental unsafety issues with software engineering practices, and C's committee is too conservative to consider retrofitting the necessary features to be able to fix unsafety at a language level (to say nothing of getting people to use it).
There is already a small clutch of languages that can serve C's niches that don't have the same fundamental unsafety issues, and right now, we're sort of at an experimental stage of system software trying them out. It's not unreasonable to believe that within a decade or so, one or more of these languages would be considered a standard, safe choice for implementing new systems software--and the use of C in new projects will start dropping. At some point, the proliferation of non-C systems projects will make people point out that having these components talk through C's ABI is too limited in functionality, and a system will change its ABI from C to some other language. And once it is no longer the language of ABI, C will lack its moat that keeps it alive, and it will start dying, though its death will be a slow, agonizing death.
Alongside RAII for resource management.
Namely, if it has to be "replaced", that would be with something with a much simpler syntax, which will require a bit more of finger power. We don't want to find ourself locked-in by very few compiler vendors (open source or not), that only because it is not reasonable to code a real-life alternative with a small team of averagely skilled devs in a reasonable amount of time.
This language should build on C though: no enum/typedef/_generic/switch/etc, only 1 loop keyword (loop{}) only explicit sized types, no integer promotion, no implicit casts (except maybe void* pointers but number literal casts should be) but explicit casts (compile-time and runtime, without that horrible c++ syntax), explicit compile-time const (we have only runtime consts which could be optimized as compile-time consts), enforce extern for functions (and don't try to put the binary format, elf/coff/etc, semantics into the language syntax or worse, the OS interface semantics), etc.
With enough discipline (and compiler warnings), we could get close to such language.
I did not check the latest and greatest rust syntax, but is what's above its explicit goals?
That said, I am a "everything in 64bits RISC-V assembly with x86_64/arm64 legacy ports kind of guy"... if RISC-V is successful (I wish). We could think of high-level language interpreters (coded in assembly, for instance a RISC-V coded python/lua/javascript/etc interpreters).
And something must be done about breaking changes of the syntax (or any never ending "features" additions).
We all know that some syntaxic constructs will be nasty in the end and will reasonably need fixing (basically, to keep them excrusiatingly simple from a compiler writing point of view). I am thinking about something like "syntax breakage provisions" from the language authors: for instance, no more than 4 iterations of major syntax breakages, then the language syntax will be frozen for forever.
Whatever, I am a everything in assembly kind of guy (with high-level language interpreters written themselves in assembly).
All that is a thought experiment for me, nothing more.
The "benchmark" to run to evaluate syntax complexity toxicity, for a compiled language, is how long an alternative compiler written by a small teams of averagely skilled devs, or even one individual averagely skilled dev, can stay a "real life" "working" alternative.
Mid-term/long-term planned obsolescence of computer language syntax is really...
Oh, and in my previous post: for compile time constants we can use static consts, my bad.