6 ms·
C is the desert island language
- kbenson 8y agoDespite its age, despite many flaws, C is still the de facto standard, the lingua franca. Why? As with other older languages, inertia is partly to blame, but this cannot be the only reason. C must possess a near-perfect balance of vital language features. A flawed premise. Why must C contain a new-perfect balance of vital language features to persist? Why can inertia and familiarity not be to blame? It's fine to list C's qualities, it has many (and it also has many warts), but if your opening statement makes two very powerful and clear assertions such as those, you would think they would be the point of the article, or at a minimum addressed within the body. They are not.
- adrianmonk 8y agoA more accurate formulation might be something like this: positives(C) - negatives(C) + inertia(C) > positives(other) - negatives(other) There are multiple things on both sides here. The author more or less asserted without evidence that inertia isn't the dominant term. Also, inertia might not be a good analogy. Things with inertia might move slowly but will move eventually even given the smallest force. This is probably more like energy wells where you can become trapped in a local minimum.
- eridius 8y agoinertia + friction then.
- Dylan16807 8y ago> easy for humans to understand > I can roughly envision the assembly generated by a C statement, so I can make educated guesses about time and space efficiency. Ha, that sure went out the window in more recent years. And everything else listed is pretty minor.
- glitchc 8y agoI started off with C 15 years ago, but now I find myself migrated, by and large, to C++. Everything that's good about C exists in C++, and all of the missing components (string support, smart pointers, tuples, maps, STL data structures) make life much easier. On top of that, it's the exact same compiler for both C and C++ on most platforms.
- Sir_Cmpwn 8y agoThankfully everything that's bad about C++ is absent in C. My least favorite term in CS is "C/C++" because they are two totally different languages, suitable for for totally different problems, and C++ is a smear on C's otherwise good name.
- jey 8y ago"C++ In the spirit of C" seems to be the sweet spot for me; think of a C++ programmer retreating to C but still keeping their fancy new C++ compiler.
- Sir_Cmpwn 8y agoYou're probably better off using Go then. If you like C++ but wish it were better you want Rust, and if you like C but wish it were better you want Go.
- jey 8y agoIn Go I can't `extern C` and calling C functions is expensive. I will probably be using Rust for some projects in the future, but right now I'm reliant on C++ for stuff like Eigen (numerical linear algebra) and OpenMP (shared memory loop parallelism).
- bestouff 8y agoThen you'll probably like Rust + nalgebra + rayon.
- 8y ago
- AstralStorm 8y agoI've had just a cursory read through the C++ vs C version. Constructors can never fail? Nope, exceptions. If you think constructors should never fail, I think you haven't used malloc. Templates are complex? Compared to preprocessor they're child's play. They're meant to replace most uses of preprocessor. Other compile time code like constexpr is not mentioned. Exceptions are not mentioned yet are actually the most complex C++ machinery. Scope changes are not mentioned but are critical to RAII and other useful anti-bug features. That you can actually enforce compile time type safety is not mentioned either. Lambasting the extra visibility keywords when C already has the nastiness of static, extern and inline is very peculiar. They are also essentially type safety measures. C++ standard library which is strictly superior to C is not mentioned either. C++ may not be perfect but at least it is being improved. C is the unchanged ancient form where the main gain is that it does not have stack frame unwinding and has trivial ABI.
- RcouF1uZ4gsC 8y agoJust another point of reference. The compiler the author uses to compile C, gcc, is actually now written in C++.
- deleted 8y ago[deleted]
- x0re4x 8y agoNo, GCC is still written mostly in C. Try: git clone --depth=1 https://github.com/gcc-mirror/gcc.git https://github.com/gcc-mirror/gcc.git cloc gcc/gcc
- comex 8y agoThe files have the .c extension, but they're actually C++. …Yes, really. They didn't change the filenames during the migration.
- noncoml 8y agoSure, C is great in its simplicity but the world has moved on to safer more powerful languages. Yes, I am referring to Rust, and yes, while it can be awkward and annoying sometimes with it's ownership lifetimes, as a professional it gives me great confidence to know that the next crash in the system will not be because of my code.
- xfer 8y ago> Sure, C is great in its simplicity but the world has moved on to safer more powerful languages No it hasn't and i am not so sure, it ever will. Good to hear that you have moved onto Rust, but that anecdata doesn't mean the world has moved on.
- noncoml 8y agohttps://insights.stackoverflow.com/survey/2018 https://insights.stackoverflow.com/survey/2018
- kahlonel 8y agoI find it ironic that the "system" that you're writing Rust code for is entirely built in C :)
- kbenson 8y agoNot necessarily. While the Windows kernel is supposed to be written in C, my understanding is that the majority/almost all of the rest of the system is written in C++. Also, I think a good portion of OS X is/was written in Objective C, which some newer portion being written in Swift.
- gnfurlong 8y agoWasn't OSX originally a fork of FreeBSD? Parts of it may have been replaced over time, but I would think that a large portion is still written in C.
- muh_gradle 8y agoThere's way too much love for C when it has some huge flaws. I can agree on simplicity, portability, speed. But having archaic String and file handling are huge frustrations. Function pointers are nice, but modern languages already have functional programming constructs that supersede it. Goto's should be avoided for good reason. As for brevity? How about just having good naming in your variables. Something that isn't HammerHammerHammerFactory but something that doesn't require a user to sift through the entire code to guess what an important variable does because it's a three character variable.
- Koshkin 8y ago> * it has some huge flaws* It's like saying that assembler is flawed. It's not; it's just may not be the right tool for the job.
- BenoitP 8y ago> Or as Linus Torvalds puts it, “C is the only sane choice”. I'd be very interested in his opinion of Rust
- steveklabnik 8y agoHe's only ever made one statement, in 2016: https://www.infoworld.com/article/3109150/linux/linux-at-25-linus-torvalds-on-the-evolution-and-future-of-linux.html https://www.infoworld.com/article/3109150/linux/linux-at-25-... > Q: What do you think of the projects currently underway to develop OS kernels in languages like Rust (touted for having built-in safeties that C does not)? > > A: That's not a new phenomenon at all. We've had the system people who used Modula-2 or Ada, and I have to say Rust looks a lot better than either of those two disasters. > > I'm not convinced about Rust for an OS kernel (there's a lot more to system programming than the kernel, though), but at the same time there is no question that C has a lot of limitations.
- noncoml 8y ago> Do you say “taxi cab”, or “taximeter cabriolet”? Rly? Tht how u tlk?
- virtualritz 8y agoThis site is critically lacking a comparison of C and Rust. The latter would be my desert island language of choice. ;)
- Koshkin 8y agoIt would keep you busy for sure...
- ivraatiems 8y agoThis article is frustrating to me. So many modern languages and toolsets are omitted from the comparisons provided that the conclusions, to me, lack authority. But they're presented as if they're obvious, almost trivial. I have great respect for C. But it's only one language and it solves one set of problems. I'm not even sure the concept of a "desert island language" is valid - except to ask "what tool would you want to have to build the tools you actually want?" In that case, the answer might be C, but the article doesn't do any kind of job showing that.
- upofadown 8y agoPretty sure that Forth is the desert island language if that means that we are starting from machine code. If we get to pick an entire language ecosystem then I choose the one with the best boat building libraries.