7 ms·
And is now obsolete, for the most part. Unless you want to do something on hardware that only has C support, there are generally better options. The language ha
by bachmeier 7y ago
And is now obsolete, for the most part. Unless you want to do something on hardware that only has C support, there are generally better options. The language has not evolved. There are now several good alternatives in this space.
Edit: Rather than responding to all the comments individually: There's obviously a lot of code already written in C. That doesn't mean it makes sense to write new code in C. Sometimes C is your only option, which I already said in my original comment.
None of that means there is any reason to start a new project in C if it's going to run on Windows or Linux, and it's certainly not the case that you have to write your program in C if you want to call it from another language. Sorry if this disappoints anyone, but it's true. For the traditional uses of C, such as writing a text editor or a library for numerical computing that you're going to call from another language, there's no longer a sensible argument for using C.
- Koshkin 7y agoJust do not expect Linux (the kernel) to be rewritten in some other language any time soon.
- marcosdumay 7y agoWe will have to move to microkernels at some point. Maybe this is the correct point.
- ncmncm 7y agoHypervisors, most likely. Linux (like the BSDs) being C is an organizational phenomenon. There is no plausible technical reason for it not to be, or include parts in, C++. History is path-dependent; how we got here matters more than what is around today. There is really no excuse for systemd being C. It is really a drag on its development.
- pjmlp 7y agoUNIX and C are symbiotic, to get rid of C we need to get rid of both. On the OSes that aren't just plain UNIX clones, C has a much less relevant role, and in some of them it is even being phased out, even if it might take a couple of decades yet.
- Koshkin 7y agoI vaguely recall that Windows originally was leaning towards Pascal.
- ncmncm 7y agoAt the time everyone was sure that Pascal was The Future of both OS and app development. What happened instead was that everybody had their own Pascal dialect with the extensions it needed to be actually useful. Meanwhile, C had them all, already, and was about the same everywhere. Soon after, C++ came along, and there was again only one (although Microsoft delivered workable template support very late). Lesson in Network Effect there. Also, shooting for usefulness out the gate. Meanwhile, the Pascal crowd went off with Modula-2, Modula-3, Oberon, Apollo Pascal, UCSD Pascal, Object Pascal, Delphi, and countless others, none compelling. Apparently Delphi (still) has economic importance. The rest, not so much.
- pjmlp 7y agoIt used the Pascal calling convention, however Lisa and Mac OS were implemented in a mix of Pascal and Assembly. Pascal UCSD also used a mix of interpreter and later AOT compiler. Most mainframes don't use C as their original implementation language, and the oldest still being sold (Unisys ClearPath MCP) was designed about 10 years before C was born, in an Algol derived language, that uses instrics instead of Assembly. If one broadens their horizons beyond UNIX, and looks into the history of computing there are plenty of interesting languages and OS architectures to dive into. The Internet is full of digitalized version of papers and computer manuals from those days.
- codr7 7y agoExcept the entire world basically runs on top of C, and any library that wants to be usable from different languages is still written in it. Which is a pretty weird definition of obsolete. Don't use it if you don't want to for whatever reason, but spreading FUD to protect your bubble doesn't help anyone. C is the most successful programming language ever designed, and a fine tool in the right hands. It's not perfect, nothing is, anyone telling you otherwise is lying.
- ChrisSD 7y ago> any library that wants to be usable from different languages is still written in it. This part isn't quite true. All that's needed is to be able to define an exported function with a specific name and calling convention. Libraries can be written in any language that supports these features.
- codr7 7y agoI used to do some of that in Borland's Object Pascal, which sort of works but isn't much fun. Even C++ is a pain in the behind, because everything that doesn't translate needs to be encapsulated. As a result, it's very rare to find code written in different languages with exported C APIs from my experience.
- fanf2 7y agoAnd the language needs to hide its runtime support so it appears to be as minimal as C
- ensiferum 7y agoAnd anything that C can do C++ can also do but better and easier and safer. So yeah... Obsolete.
- codr7 7y agoThat's just not true, because C++ won't even allow many of the techniques that make C the awesome language it is. It's different, and that's about as far as it goes. Add name mangling, ABI issues and crazy compile times to that. It was potentially safer until they added Exceptions, which tipped the scales so far the other way I can't believe we're still having this discussion.
- marcosdumay 7y agoThere is no good alternative for doing some low level thing where you must have fine control over IO or execution sequence. Rust is the best candidate, but it operates on a completely different level. (That said, I don't think one ever need that much control on a PC or a server. Not even on kernel programing.)
- squarefoot 7y agoThe language hasn't evolved for the same reason a transistor hasn't evolved: because it didn't need to. Adding for example string manipulation, or graphics, etc. would make it a fantastic language, but it would lose being that minimalist tool which makes it often the best choice when writing low level stuff. To me, Crystal, Nim, Rust, Go etc. already fulfill that need. About the electronics comparison, I can build a lot of complex stuff more fast and more easily using opamps or logic gates compared to discrete transistors, but if I need to do a simple basic task such as invert a logic signal or amplify an analog one I'm using a single transistor any day because it doesn't just spare all that wasted silicon in chips but also in many cases it will be more fast, more cheap and more quiet noise-wise.
- ncmncm 7y agoWrong. Transistors have evolved in dozens of directions. The old transistors are still used, but decreasingly so. It is likely an op amp does better what your transistor and a bunch of other stuff did, and equally as cheaply. The op amp might have bipolar transistors in, but just as likely not. C has not evolved because C++ has, and because the computers got a million times faster, so even Python is usually good enough. If you need something that does what C does, but better, C++ is right there waiting. Change your makefile, or rename some files, and suddenly you have a C++ program, that is then easy to improve as much as you like.
- flavio81 7y ago>C has not evolved Well, it has, in a way: see the latest C standard and compare it with the Kerninghan&Ritchie edition.
- ncmncm 7y agoC has barely changed since 1989. It already had void and function prototypes copied from C++, back then. Only atomics and restrict make any real difference.
- flavio81 7y ago>The language hasn't evolved for the same reason a transistor hasn't evolved: because it didn't need to. That's what you think. Transistors have evolved a lot, as have programming languages.
- Touche 7y agoC is basically your only option for embedded systems.
- ncmncm 7y agoFalse, of course. It's the only language your chip vendor will give you, but there is very little reason ever to use their compiler, anymore. And they have no say in what you use to generate your machine code.
- pjmlp 7y agoDepends on the project and chip vendor. Anyone that is open mindend can get Pascal, Basic, Java, Oberon, C++ and Ada compilers, although I admit that the Ada option is only available for deep pockets.