Remix.run Logo
▲ kanbankaren 5 hours ago

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!

▲glouwbug 3 hours ago | parent | next [-]

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

▲ricardobeat 2 hours ago | parent [-]

C3 lang gives you defer + a lot of significant ergonomic improvements right now: https://c3-lang.org

▲feelamee an hour ago | parent | next [-]

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.

▲glouwbug 43 minutes ago | parent | prev [-]

C3 is very good

▲prophittcorey 5 hours ago | parent | prev | next [-]

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.

▲kevin_thibedeau 4 hours ago | parent | prev | next [-]

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.

▲PaulDavisThe1st 4 hours ago | parent | prev | next [-]

It's what we did at amzn in 1994 ...

▲bigbuppo 2 hours ago | parent | next [-]

Wasn't amazon running on tandem back then?

▲PaulDavisThe1st 2 hours ago | parent [-]

In 1994, amzn ran on a single solaris workstation. Same at the beginning of 1995. I can't comment after that.

▲ 3 hours ago | parent | prev [-]
[deleted]
▲ricardobeat 2 hours ago | parent | prev [-]

There is a huge mental overhead penalty...