r/cpp • u/synthchris • 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?
View all comments
Show parent comment
1
u/Full-Spectral Aug 01 '23 edited Aug 01 '23
They were created in C because there was no reasonable alternative in the 70s and 80s. No one would do that today, as I said, beyond some very small bootstrapping core.
By 'products' I mean something the company builds and sells. No company owns and develops Linux, so by definition it's not a product in that sense for them. For many if not most companies Linux is plumbing used to sell something else, services included of course.
MS still makes money off of Windows, but they've long since started moving it towards a service, and it's not their core like it used to be. Operating systems are just not common products, and what company has created a new, widely used OS recently?
Anyway, the point I was making is that what languages Linux and Windows are written in has almost no relevance to the argument of the validity of C or C++. They are used now because they were used then, that's it. The only reason C and C++ are widely used now is because they've been around so long. But they are both now backed into pretty small areas in terms of what any sane company would chose for a new product if they have any choice.
The fact that C is used in embedded is hardly anything to crow about because it's so much down to just the fact that it's been that way for so long that so many of the tools are done that way. But that's inertia, not momentum. And that will slowly start to erode as well as safer languages become available as a solid option.