upvote
I didn't want to state why C and not "X" because the comments would have devolved into an all out language war.
reply
As someone who works on C compilers, I find the obession with C language insane.

For any greenfield project, pick up C++ in lieu of C if you want a C language.

There is no runtime penalty for using C++ if you stick to plain structs and don't use virtual functions, but you get better static type safety, lvalue references, namespaces, etc. even if you don't use the OO features.

Even for virtual functions, the overhead is minimal that it is just noise.

C compilers themselves are written in C++ for the last 15 years. Oh, the irony!

reply
Because in practice it’s really hard to not succumb to C++ feature creep. You start with good intentions and limit yourself to namespaces and structs, but then the “this will benefit from a vector, or this from a map” appears, then you realize you’d like a templated use case, and a single raw pointer or resource handle from a call to something like fopen() suddenly is not releasing its resource on a linked list pop and now you’re writing move semantics on top of copy semantics because a destructor declaration silently enforces copies on a std::move without move semantics. You reach for a unique pointer and, and all of a sudden, you have most of modern C++ without a single virtual call.

So people obsess over C because you’re hard limited by the upper feature bound. And that’s not so bad because C gets feature updates too - microscopic but effective feature updates; see C29 for the poor man’s RAII: defer

reply
C3 lang gives you defer + a lot of significant ergonomic improvements right now: https://c3-lang.org
reply
and what it does take away? most "better C" languages basically looks like C++ (except zig, maybe). Nobody write something real in them, so nobody knows about their pitfalls.
reply
C3 is very good
reply
I generally like "C-style C++", but I find it difficult to draw the line between C and C++. It's too easy to keep reaching into C++ for "just one more thing."

That may be a me problem.

reply
T> here is no runtime penalty for using C++

Large portions of the standard lib depend on heap allocations. C is a much safer target for environments with limited resources.

reply
It's what we did at amzn in 1994 ...
reply
Wasn't amazon running on tandem back then?
reply
In 1994, amzn ran on a single solaris workstation. Same at the beginning of 1995. I can't comment after that.
reply
deleted
reply
There is a huge mental overhead penalty...
reply
Fair enough. But I am also curious if you'd like to share your rationale.
reply
I can never figure out why everything isn't in C. :|
reply
Is it because you segfault before reaching the answer?
reply
A segfault IS the memory protection taking in effect.
reply
The underlying libraries you use tend to be in C anyway, so it simplifies things to just use them with their native interface, and not having to add another language runtime and its idiosyncrasies.
reply
Yesterday or so there was a post about using Zig. When I read it I thought that using C would work equally well.
reply
Yeah, I thought it was interesting that both of these[0] were on the front page.

[0] - the other one: https://news.ycombinator.com/item?id=50051573

reply
I'm old enough to remember when the OKCupid guys wrote their own webserver in C++!

I took the concept of "slots" in requests, from it: https://github.com/okws/okws

reply