Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> ...many C programs will compile just fine with a C++ compiler

Unfortunately(?) that's only true for C code written in the early 90s or specifically for the common C/C++ subset (which is essentially a subset of both C and C++ based on a non-standard snapshot of C ca 1995).

Since C99, the two languages have diverged enough that C is no longer a subset of C++, and IMHO propagating the idea that there's a 'C subset' in C++ 25 years after the 'schism' is harmful both for C and C++.



I feel like the article is already implying this:

> Despite this, C++ preserves a huge amount of C heritage and many C programs will compile just fine with a C++ compiler

It preserves "a huge amount", not "backwards compatability". "Many" C programs will compile, not "all". Hell, the author didn't even go as far as to say "most".

Also the author says:

> The original version of C++ WAS basically an object oriented version of C ("C with classes") BUT AT THIS POINT it has been around for 40-odd years and so HAS DIVERGED VERY SIGNIFICANTLY

[my emphasis / capitalization]

I'm not sure what point you're making that's not already in the article.


Partially, ISO C++ has been updating the underlying C standard library reference, to the extent it is compatible with C++, C++23 refers to C17 and the upcoming C++26 will refer to C23, standard library that is.

However this is exactly the golden example why guest languages never own the platform (in this case UNIX/POSIX/C trio), and eventually the platform and guest always diverge.

Even though both share the same birthplace, as usual adoption takes different routes.

If one never wants to face this, regardless how many pain points the language owning the platform has, sticking to it always wins out in the long run.


There are people on the C standard commitee with their main goal keep C tompatible with C++. They don't win ever debate but they win many.


I don't doubt it, unfortunately design by committee has its constraints.

For example, had C kept under control by its authors, maybe even the security story would have been sorted out by now, who knows.


Interestingly though, compatibility in the reverse direction has actually gotten better over time. C99 allows variables to be declared at any point in a function. Before C99, the all variables up front rule used to be the single biggest reason that C-style C++ code wouldn't compile under a C compiler.


Many C compilers accepted this as non-standard extension already before C99 though (along with winged comments, and `for (int...)`).

There is a lot of useful harmonization happening between the two languages (and mostly from the direction of C++ to C)

From the perspective of a C coder, the one good thing about C++ is that it is basically the testing ground for new potential C features to figure out what works and doesn't work in realworld scenarios before the C standard is polluted too much with the ideas that don't work ;)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: