3 ms·
But that's the thing, code bases are full of non-standard C, but they never break because the C standard changes, only because their weird hacks are falling out
by jeroenhd 2y ago
But that's the thing, code bases are full of non-standard C, but they never break because the C standard changes, only because their weird hacks are falling out of favour. Fixing a design flaw in C will break all existing code, instead of the code of the dozens of companies relying on weird hacks they wrote ten years ago.
Once Zig becomes stable, I think it may have a chance of slowly fixing existing C code bases, by its virtue of being able to co-exist with existing code bases. On the other hand, a lot of C programmers don't want to change because they don't see a problem, so the presence of those will probably ruin any chance Zig has of improving the situation.
- samatman 2y agoOther than the pessimistic finish, my prediction is that this is exactly what will happen. The change will be a generational one. C will never entirely disappear, but over time, C code will be old code. People will occasionally write new C for what amounts to aesthetic reasons, and there will be a robust niche (doubtless well-paid) of maintainers of legacy C projects. All the kernels currently written in C will still exist, and still be composed mostly or entirely of C. But new work in embedded, drivers, implementation of programming languages, netork stacks, will be in Zig instead. With some Rust as well, but I figure we've seen enough of that arc to tentatively conclude that what Rust is displacing is mostly C++, not C. But when I say generational, I mean it. You're quite right that there is a legion of C programmers who like it and intend to stick with it. But they'll retire one day.
- jeroenhd 2y agoExcept for maybe in kernel projects, C code already is old code. As far as I can tell, (modern) C++ is the oldest common language for new projects. Rust is already part of the Linux kernel, being used for rather complex things like GPU drivers in Asahi. Android rewrote their Bluetooth stack into Rust and Windows is actively replacing existing operating system components with Rust as well. I don't think we'll need to wait for Zig to start replacing old C code, it's already being replaced with Rust now. I think Zig would've been a better choice for some parts, but it's taking too long to become stable for it to be included in large projects. Still, it may be useful for people working on embedded stuff, as embedded code seems to be stuck with 90s C when it comes to language support, if someone can manage to write a compiler backend for that specific embedded chip.
- pjmlp 2y agoIn many places outside the UNIX FOSS sphere and hardcore embedded devs, C++ keeps replacing C already, that includes Apple, Google and Microsoft OSes. While Rust might be a better alternative, C++ is already much better than raw C.
- qiqitori 2y ago> Once Zig becomes stable Zig was introduced in 2016. If it still isn't stable 8 years later, I wouldn't hold my breath.
- jeroenhd 2y agoRust began in 2006 and became stable in 2015. Zig still has a year at the very least! Zig lacks the corporate backing Rust had, though, so it's hard to say when they'll get stable. Regardless, even if it'll take Zig a decade, I'm sure it'll have a stable release with decent memory management as part of the language spec before C will.
- pjmlp 2y agoZig is basically the Modula-2 features (1978) in a more C like friendly packaging, with an additional metaprogramming capabilities. It needs a bit more than only corporate backing for taking off, something that makes it unavoidable, specially given the alternatives.