Live data from Hacker News

C++ is not a superset of C

mcla.ug

91–100 of 114 posts

Re: C++ is not a superset of C

#91
post #73
post #58

Earlier quoted context omitted.

To be exact, it doesn't compile fine outside of functions (which the sample code didn't have) because file scope arrays can't be VLAs.

This is what I was going for in the blog post, but I got confused after seeing these comments as Clang _does_ compile this when the buffer is of static storage class. Which I don't think is standard -- but it's not using VLAs. I wondered if it just has constant expression semantics for const variables. Weirdly, adding a _Static_assert to test this theory proves it for c99 but not c11 :/ https://godbolt.org/z/q-bb-n c…

The C standard permits implementations to support additional forms of constant expressions.

Try "clang -std=c11 -pedantic-errors".

Re: C++ is not a superset of C

#92

I love that roughly 35 years after its creation we're still arguing about what c++ is or is not in relation to C. I'm looking forward to the debates and blog posts of my grandchildren on Perl 6 vs Perl 5

Doubt either of our grandchildren will ever use Perl. It is truly an arcane language that has no niche and no new application written in it.

I'm still using perl scripts for log parsing and some general sys-admin type stuff, but yeah, it's way past its prime.

Re: C++ is not a superset of C

#93
post #54

Earlier quoted context omitted.

> Are they trying to make C literally become the same as C++ except classes and templates? As a C programmer, aren't classes, templates, and exceptions the things that have classically differentiated C and C++?[0] I don't see anything obviously objectionable about nullptr[1], auto, __has_include, or constexpr. (I don't have a ton of experience with them, either.) I'll admit I don't really grok what "make false and tr…

> This means that it cannot be used safely in portable incantations of variadic functions that expect pointer arguments. Why only variadic functions? The answer to that may make my next question obsolete, namely: Wouldn't only C++ complain about this? In C, isn't the input to anything coerced to the data type it will represent, in actual complete disregard of the input type?

[deleted]

Re: C++ is not a superset of C

#94
post #16
post #11

Earlier quoted context omitted.

I've definitely heard c++ described this way.

It was a superset, once. C++ started as a C preprocessor. But the languages have diverged. It's enough of a superset, though, that C++ hasn't deleted bad features of C, like pointers and arrays being the same thing.

Pointers and arrays are not the same thing. See section 6 of the comp.lang.c FAQ, http://www.c-faq.com/ .

I doubt that C++ was ever a strict superset of C. Has

    int class;
ever been a valid declaration in C++?

Re: C++ is not a superset of C

#95
post #67
post #57

Earlier quoted context omitted.

I am hoping this isn’t an implication that C is legacy and C++ is the modern and the future. :-)

Not that I've worked in a lot of places, but everywhere that I've worked that uses C at all treats it this way. Writing new C code is considered a no-no.

I write C every day at a major silicon valley networking company. So it's not at all considered bad.

Re: C++ is not a superset of C

#96
I've made some updates to the blog post based on feedback -- thank you everyone who pointed out mistakes helpfully :)

I've made the updates clear, and linked to the archived version of the original post.

Re: C++ is not a superset of C

#97
post #78
post #57

Earlier quoted context omitted.

I am hoping this isn’t an implication that C is legacy and C++ is the modern and the future. :-)

C isn't just legacy, it's fundamentally broken. Rust is the future. C++, while it mitigates some of the brokenness of C, favored backward compatibility with C over fixing the brokenness once and for all.

I love Rust as much as the next guy, but not everything that was a good fit for C is necessarily a natural transition to Rust.

Re: C++ is not a superset of C

#98
post #54

Earlier quoted context omitted.

> Are they trying to make C literally become the same as C++ except classes and templates? As a C programmer, aren't classes, templates, and exceptions the things that have classically differentiated C and C++?[0] I don't see anything obviously objectionable about nullptr[1], auto, __has_include, or constexpr. (I don't have a ton of experience with them, either.) I'll admit I don't really grok what "make false and tr…

> This means that it cannot be used safely in portable incantations of variadic functions that expect pointer arguments. Why only variadic functions? The answer to that may make my next question obsolete, namely: Wouldn't only C++ complain about this? In C, isn't the input to anything coerced to the data type it will represent, in actual complete disregard of the input type?

colonwqbang hit the nail on the head.

For non-variadic functions, the function declaration provides the correct parameter type, and caller arguments are coerced to the correct type.

> In C, isn't the input to anything coerced to the data type it will represent, in actual complete disregard of the input type?

In short: no. Implicit casts between incompatible types are warnings/errors.

Re: C++ is not a superset of C

#99
post #81
post #74

Earlier quoted context omitted.

C is a niche language and C++ is about to hit the wall as companies abandon it for languages like Go and Rust.

You're high. In industry C and C++ are very widespread. Go and Rust are ... not. You'll have an easier time finding a job that requires FORTRAN than one requiring Rust, and Go is only a bit more popular.

Lets touch base again in five years and see how C++ is doing.

Re: C++ is not a superset of C

#100
post #67

Earlier quoted context omitted.

Not that I've worked in a lot of places, but everywhere that I've worked that uses C at all treats it this way. Writing new C code is considered a no-no.

I write C every day at a major silicon valley networking company. So it's not at all considered bad.

It is considered bad at many other places.

I would add, more enlightened places.

But competent C++ programmers are expensive. It is harder to tell whether a C programmer is competent, because the code they write has less room to be better than minimally tolerable.

Post reply on HN