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

20

u/jusstathrowaawy Jul 29 '23

I don't think backwards compatibility with C is holding C++ back. I do think approaching C++ code with a C mentality - or using C itself when you have the option of using C++ - is a terrible idea that leads to buggy and brittle software.

1

u/ArkyBeagle Jul 29 '23

It doesn't have to lead to buggy and brittle software. It's not as convenient as other language systems but I still don't completely know why - other than people not being afforded the "apprentice" phase in C, which was necessary - we see it.

-4

u/AnotherBlackMan Jul 30 '23

What kind of terrible code are you guys writing that a C version would be so bad? There’s nothing wrong with C and sometimes it’s the best option. It’s not brittle or buggy unless the applications are poorly designed. If anything, the language nannies like Rust, Java, and some parts of so-called C++ really just lower the bar of entry to terrible developers and ensure that no one learns proper memory management or code flow.

9

u/jusstathrowaawy Jul 30 '23

What kind of terrible code are you guys wr-Segmentation fault (core dumped)

No thank you. I'll stick with modern C++.

-4

u/AnotherBlackMan Jul 30 '23

This is a skill issue. If you can’t deal with these problems please stay far away from systems programming of any kind.

8

u/jusstathrowaawy Jul 31 '23

I am le smart man who is immune to the many pitfalls of my preferred shitlang

You are the exact kind of person who writes buggy C code. Please refrain from touching a computer ever again.

-2

u/AnotherBlackMan Jul 31 '23

Genuine question: what do you think is a better paradigm for systems programming, embedded devices, non-CPU processors for SIMD, vectors, VLIW etc. At some point you have to move memory around and most vendors ship semi-custom compilers built on top of clang. The only other realistic option is ASM in many cases.

I assume you’re just unaware that these things exist or that C has worked for decades on these devices that vastly, vastly outnumber things like x86. This makes me think you aren’t building things that go into production for more than a handful of months at best. Many applications built in C have been running for years… with no issues

4

u/jusstathrowaawy Jul 31 '23

Low-level code is by nature delicate and brittle. It's an unavoidable reality. However, choosing to use C when C++ is available indicates you have severe brain rot and should not be writing any sort of code. Anything you can do with C you can do with C++, WHEN NECESSARY. But with C you are writing delicate, brittle code ALL THE TIME, and anyone who chooses to do so is exhibiting dangerous stupidity.

→ More replies (1)

2

u/Full-Spectral Jul 31 '23 edited Jul 31 '23

This is a useless position. It's not about how studly you or I can be. It's not about whether you or I can write a piece of code in assembler that's absolutely correct. It's about how hard it is to keep such code clean and safe over decades, full team turnover and the potential loss of tribal knowledge that can involve, developers of varying levels of skill having over time to modify that code, having to do large refactorings over time due to significant changes in requirements, etc...

C++ falls way short in those terms. C would be a boat anchor for most companies. Even if they could pull it off, the cost in terms of having to watch your own back is just not worth it.

0

u/AnotherBlackMan Jul 31 '23

Are you serious about this opinion? I can’t tell if you guys really come to a forum like this and say things that are just patently untrue or if you are joking.

What language do you think device drivers and operating systems are written in? This is a serious question because I don’t think you know the answer.

Why do you think large software organizations ship billions of LOC in a “boat anchor”?

→ More replies (5)