News for hackers. Stuff that matters.
Re:A Modern Web App in C by prophittcorey on Monday October 12, 2026 @01:23PM (#50059682)
I didn't want to state why C and not "X" because the comments would have devolved into an all out language war.
Re:A Modern Web App in C by kanbankaren on Monday October 12, 2026 @02:30PM (#50060716)
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!

Re:A Modern Web App in C by glouwbug on Monday October 12, 2026 @04:20PM (#50062437)
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

Re:A Modern Web App in C by ricardobeat on Monday October 12, 2026 @04:51PM (#50062907)
C3 lang gives you defer + a lot of significant ergonomic improvements right now: https://c3-lang.org
Re:A Modern Web App in C by feelamee on Monday October 12, 2026 @06:02PM (#50063687)
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.
Re:A Modern Web App in C by ricardobeat on Monday October 12, 2026 @08:01PM (#50064765)
What do you mean by that?

n=1 but I've probably written (sic - a lot of AI) over a million lines of it this year. I like it precisely because it is nothing like C++, it's really just a better C, and the compiler / tooling is almost as good as Go.

Re:A Modern Web App in C by glouwbug on Monday October 12, 2026 @06:35PM (#50064033)
C3 is very good
Re:A Modern Web App in C by bogdanoff_2 on Monday October 12, 2026 @11:08PM (#50066104)
> fn int foo(){

Eh? What's the point of a `fn` keyword if I can't `grep -r "fn foo"`?

Re:A Modern Web App in C by rurban on Tuesday October 13, 2026 @01:20AM (#50067087)
gcc also gives you defer nowadays, called cleanup
Re:A Modern Web App in C by uecker on Tuesday October 13, 2026 @01:26AM (#50067135)
Indeed, my experience is that just sticking to C leads to better software. I found it relieving and not limiting.
Re:A Modern Web App in C by prophittcorey on Monday October 12, 2026 @02:39PM (#50060846)
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.

Re:A Modern Web App in C by kevin_thibedeau on Monday October 12, 2026 @03:18PM (#50061489)
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.

Re:A Modern Web App in C by mpyne on Monday October 12, 2026 @10:23PM (#50065797)
So use the C standard library instead of the C++ one. You still get RAII / constructors/destructors and runtime polymorphism, along with stronger compile-time type safety.

I frequently do that myself on simple C++ programs just for compile time reasons alone, where I'll use stdio.h instead of std::iostream or std::format.

Re:A Modern Web App in C by kevin_thibedeau on Monday October 12, 2026 @11:16PM (#50066171)
Designated initializers are gimped in C++;
Re:A Modern Web App in C by throw16180339 on Tuesday October 13, 2026 @12:48PM (#50074737)
C++ 20 added designated initializers, but the fields have to be specified in declaration order.
Re:A Modern Web App in C by kevin_thibedeau on Tuesday October 13, 2026 @01:10PM (#50075144)
It partially added them. You can't use them out of order or skip members nor can you use the array initializers.
Re:A Modern Web App in C by PaulDavisThe1st on Monday October 12, 2026 @03:25PM (#50061612)
It's what we did at amzn in 1994 ...
Re:A Modern Web App in C by bigbuppo on Monday October 12, 2026 @04:55PM (#50062960)
Wasn't amazon running on tandem back then?
Re:A Modern Web App in C by PaulDavisThe1st on Monday October 12, 2026 @05:13PM (#50063149)
In 1994, amzn ran on a single solaris workstation. Same at the beginning of 1995. I can't comment after that.
Re:A Modern Web App in C by prmoustache on Tuesday October 13, 2026 @07:58AM (#50070266)
caveat: Amazon was just a simple online bookstore at the time. There was little relation to what amazon is now (no AWS for example) except it was already selling and shipping stuff and keeping an inventory like any other online store.
Re:A Modern Web App in C by PaulDavisThe1st on Tuesday October 13, 2026 @02:09PM (#50076045)
actually, in 1994/95, there was (almost) no inventory.

we invented a system we called "almost in time", the basic principle of which was "no we don't have that in stock but we can get it for you really fast". this is why we had to write our own system, because all the existing inventory mgmt systems (at least at that time) assumed that you would have at least some stuff in stock.

Re:A Modern Web App in C by prmoustache on Tuesday October 13, 2026 @05:11PM (#50078840)
That's the method of modern thieves. They advertize your stuff and only stole them when they find a potential buyer.

I've had friends finding photos of their own bicycle locked in the street advertized in second hand platforms.

Re:A Modern Web App in C by ricardobeat on Monday October 12, 2026 @04:50PM (#50062889)
There is a huge mental overhead penalty...
Re:A Modern Web App in C by zelcon on Monday October 12, 2026 @11:19PM (#50066193)
For any greenfield project, pick up Rust instead of C++. Why? Ask any AI and it will pick Rust. Since AI is writing the code now and it likes Rust, because the pre-AI internet in its most trustworthy training dataset liked Rust. Therefore all code will eventually be Rust.
Re:A Modern Web App in C by lelanthran on Tuesday October 13, 2026 @12:10AM (#50066585)
> For any greenfield project, pick up C++ in lieu of C if you want a C language.

Depends on the metric.

1. If the metric is "How many features can I have", then, sure, C++ wins - it has everything.

2. If the metric is "how few footguns are there", then C++ loses by a mile - there's too many ways that the different features from #1 above can interact with each other to make it viable to keep track of all the footguns when writing code.

You may not value having fewer footguns and/or lower cognitive burden, but many do.

Re:A Modern Web App in C by christoff12 on Monday October 12, 2026 @01:31PM (#50059802)
Fair enough. But I am also curious if you'd like to share your rationale.