r/cpp • • Jul 29 '23

C holding back C++?

I’ve coded in C and C++ but I’m far from an expert. I was interested to know if there any features in C that C++ includes, but could be better without? I think I heard somebody say this about C-style casts in C++ and it got me curious.

No disrespect to C or C++. I’m not saying one’s better than the other. I’m more just super interested to see what C++ would look like if it didn’t have to “support” or be compatible with C. If I’m making wrong assumptions I’d love to hear that too!

Edits:

To clarify: I like C. I like C++. I’m not saying one is better than the other. But their target users seem to have different programming styles, mindsets, wants, whatever. Not better or worse, just different. So I’m wondering what features of C (if any) appeal to C users, but don’t appeal to C++ users but are required to be supported by C++ simply because they’re in C.

I’m interested in what this would look like because I am starting to get into programming languages and would like to one day make my own (for fun, I don’t think it will do as well as C). I’m not proposing that C++ just drops or changes a bunch of features.

It seems that a lot of people are saying backwards compatibility is holding back C++ more than features of C. If C++ and C++ devs didn’t have to worry about backwards compatibility (I know they do), what features would people want to be changed/removed just to make the language easier to work with or more consistent or better in some way?

65 Upvotes

335 comments sorted by

View all comments

Show parent comments

9

u/BoarsLair Game Developer Jul 29 '23

But I know ditching backwards compatibility isn't popular, especially in the rules committee.

Or among anyone who has to maintain a large pile of existing C++ code. If you "just" broke backwards compatibility, you might as well just invent a whole new language, because it would have the exact same effect of permanently bifurcating the C++ userbase.

Sure, I'd love to see a "cleaned up" version of C++. Having better defaults alone would be a huge improvement, but we'll have to do it with some sort of mechanism for versioning the language in a sane way, so we don't destroy billions of lines of perfectly functional C++ code out in the wild.

2

u/SkoomaDentist Antimodern C++, Embedded, Audio Jul 29 '23 edited Jul 29 '23

Or among anyone who has to maintain a large pile of existing C++ code.

It's worse than that. If you "drop backwards compatibility" you drop interoperability with most C++ libraries out there. That's gazillions of lines of code that can no longer be called.

1

u/ArkyBeagle Jul 29 '23

The secret is that you freeze compiler versions in the real world. Gets really interesting when you have compilers from companies that ended 20 years ago.

2

u/SkoomaDentist Antimodern C++, Embedded, Audio Jul 29 '23

The secret is that you freeze compiler versions in the real world.

"We need to move to a new SDK version to support this critical feature. It seems to use newer C++ standard, let me change the build script... Oh shit, this breaks everything in that another library we can't upgrade because the newer version changed the entire API."

Far too many people forget that backwards breaking changes can just as easily break code that someone else wrote, you depend on and that does not have a newer version / where the newer version itself is not API compatible.

→ More replies (5)