Comment by prophittcorey
6 hours ago
I didn't want to state why C and not "X" because the comments would have devolved into an all out language war.
6 hours ago
I didn't want to state why C and not "X" because the comments would have devolved into an all out language war.
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!
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
C3 lang gives you defer + a lot of significant ergonomic improvements right now: https://c3-lang.org
2 replies →
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.
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.
It's what we did at amzn in 1994 ...
Wasn't amazon running on tandem back then?
1 reply →
There is a huge mental overhead penalty...
Fair enough. But I am also curious if you'd like to share your rationale.