Hacker News new | ask | show | jobs
by Jeema3000 5584 days ago
But the main reason it's not as clean is because it has had to maintain backwards compatibility with C, which is 40 years old now.

Ironically, had C++ been 'cleaner' and not as backwards compatible with C from the outset, then we probably would not be having this conversation today because no one would have ever adopted it. :)

3 comments

I disagree. The reason it's not clean is because they threw everything including the kitchen sink into it.

C is a very simple and elegant language. You can write down the specs for it on a dinner napkin. And implement a compiler for it overnight.

C++, on the other hand? A fully compliant compiler for it took over a decade.

Can you give an example of removing some backwards compatibility with C that would make C++ cleaner?
Converting static array references to pointers when passing them as a function parameter. The whole array/pointer conflation.

C's struct "tag name space".

Trigraphs and \ line splicing.

Replace #include with symbolic import.

There are counter-examples. Objective-C is a strict superset of C and a reasonably clean language.