4 ms·
C's well defended place is unfortunately mostly defended by folklore, nostalgia and a desire for one-upmanship. There are several good languages available toda
by blub 8y ago
C's well defended place is unfortunately mostly defended by folklore, nostalgia and a desire for one-upmanship.
There are several good languages available today that can successfully replace C - including at controlling RAM or the size of variables
P.S: there's a book called "The design and evolution of C++" which you should probably read. Where can one learn more about the design of C?
- simias 8y agoI disagree, C is popular for the same reason that QWERTY is more popular than DVORAK or Colemak or that x86 is more popular than ARM (talking purely from an IA perspective). It's not folklore or nostalgia, it's just that it was here first, there's a ton of legacy applications that rely on it and the cost of the switch is seen as a large, one time cost vs. the small benefits it would bring over a longer period of time. I'm a huge fan of Rust and I can only dream of having all C codebases in the wild ported to it some day but I'm still writing C at work because it's faster, easier (vendors provide C libraries and code, not Rust) and it's easier to hire C coders than Rust ones. >P.S: there's a book called "The design and evolution of C++" which you should probably read. Where can one learn more about the design of C? I'd be surprised if C was really ever "designed" the way we would design a language these days. Basically it was a fork of earlier languages tweaked to more conveniently model the hardware of the time. It was more about getting the job done at the time than making an innovative language. At least that's what I gathered from what I know about the early days of C and it's also fairly apparent in the way the language itself is designed (the whole pointer/array shenanigans come to mind). C is many things but it's definitely not elegant or even clever.
- blub 8y agoI agree with you regarding existing software - I don't think it's worth discussing too much about, since that software will either live on "forever" or be outright replaced, rather than being rewritten. I was mainly referring to new projects, where C continues to be selected because of a myriad of reasons, none related to technical uniqueness or superiority. This is truly infuriating, because we will collectively pay for those poor choices in security vulnerabilities.
- simias 8y agoStability and being able to find developer who will maintain the project 5 years from now are still very pragmatical arguments though. Again, I love Rust but I still don't feel comfortable pushing it for critical components at work because who knows where it'll be 5 years from now? Is it here to stay? If I leave my job will they find people to take over? Furthermore even brand new projects will have to interface with existing code to some extent. C bindings are everywhere, Rust not always. And even when they exist they're not always complete and are often quite experimental. Still, I'm doing my part and I did write a few smaller components of my current project in Rust at work. But it's not surprising that the shift is not happening overnight.
- pjmlp 8y agoExcept that is yet another folklore, as C wasn't there first in any form or fashion. There is an history of 10 years of systems programming languages, preceding it. Prooving one does not need to throw security out of the window in systems languages. Had Bell Labs been allowed to sell UNIX, instead of giving it away for a symbolic price and C would have been a footnote on history of system languages.
- simias 8y agoThe parent was talking about "nostalgia" and "replacing C" so I assumed they were talking about more recent languages like Rust, C++, D, Go, Zig and all these newer system languages. I agree that if we're talking about why C took over in the first place it's a different discussion.
- nwmcsween 8y agoThere are no current languages that can displace C, none, zero. If you want a language that _will_ displace C it needs to be designed and features mapped, interactions, pros, cons, etc so others can understand it and __why__ choices were made.
- pjmlp 8y agoExcept that C++ is already doing that, even if slower than desired. AUTOSAR now requires C++14 compliance on software certification. Android, ChromeOS, Windows, Apple OSes native components are mostly written in C++. Finally, all major C compilers are written in C++ nowadays. The only places where C++ is failing to replace C, is among developers unwilling to move beyond C89 on embedded space, or UNIX clones.
- nwmcsween 8y agoC++ is evolved not designed from the start. A properly (IMO) designed language would have a pro, con wiki/ graph map and features would have _all_ interactions mapped. C isn't this either but it doesn't try to paint over bad feature interactions by adding more.
- pjmlp 8y agoYes, because C99 was such a design success with mistakes being made optional in C11.
- nwmcsween 8y agoI'm not advocating for C, I'm just describing a language that could displace C while having some good features. C takes features to the extreme by having few and being somewhat simple, a language designed as I stated could have features and still remain simple.
- blub 8y agoI've already pointed another person to the book "The design and evolution of C++" which I believe puts the not designed argument to rest. But it is impossible to create a beautiful, "properly designed" programming language that's also backwards compatible with C. I mean look at Objective-C :)