
C is the desert island language - signa11
http://www-cs-students.stanford.edu/~blynn/c/intro.html
======
AstralStorm
I'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
Just another point of reference. The compiler the author uses to compile C,
gcc, is actually now written in C++.

~~~
x0re4x
No, 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
The files have the .c extension, but they're actually C++.

…Yes, really. They didn't change the filenames during the migration.

------
kbenson
_Despite 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
A 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
inertia + friction then.

------
glitchc
I 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.

~~~
flohofwoe
For me it's exactly the other way around. Spent 20 years in C++ (before that 5
years of C), but slowly and steady got fed up by the language complexity,
redundant features, standard library bloat and compiles times. Went back to C
and it's like a breath of fresh air.

The turning point for me was realizing that C++ mostly helps with managing the
complexity of many small memory allocations, but it's better to avoid such a
"many small memory allocations" scenario to begin with. And without that, C++
looses much of its appeal over C.

~~~
Ace17
Don't you miss virtual functions? I found that no matter how you did it,
implementing polymorphism in C (with function pointers) is tedious and verbose
; also, it discourages the creation of new interfaces (too much boilerplate).

~~~
flohofwoe
No, I don't use virtual methods (or inheritance, or runtime polymorphism) in
C++ that much either.

------
noncoml
Sure, 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.

~~~
qubax
> Sure, C is great in its simplicity but the world has moved on to safer more
> powerful languages.

Sure, we have more type safe languages. But I wouldn't call one language "more
powerful" than another. Certainly Rust isn't "more powerful" than C. They are
both turing complete and equally "powerful".

~~~
chii
Most uses of the word powerful in this context actually refers to the
expressiveness of the language and not the Turing completeness.

------
muh_gradle
There'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
> * 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.

------
ivraatiems
This 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.

------
virtualritz
This site is critically lacking a comparison of C and Rust. The latter would
be my desert island language of choice. ;)

~~~
Koshkin
It would keep you busy for sure...

------
BenoitP
> Or as Linus Torvalds puts it, “C is the only sane choice”.

I'd be very interested in his opinion of Rust

~~~
steveklabnik
He's only ever made one statement, in 2016:
[https://www.infoworld.com/article/3109150/linux/linux-
at-25-...](https://www.infoworld.com/article/3109150/linux/linux-at-25-linus-
torvalds-on-the-evolution-and-future-of-linux.html)

> 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.

------
upofadown
Pretty 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.

------
Dylan16807
> 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.

------
noncoml
> Do you say “taxi cab”, or “taximeter cabriolet”?

Rly? Tht how u tlk?

~~~
Koshkin
In programming (and also in mathematics, physics, chemistry, microbiology,
etc.), yes.

~~~
noncoml
The article was saying that it's OK to do it in programming because we do it
in real life. My point was that we don't.

