While I applaud the passion in this article the issue is so old that people just roll their eyes and move on. We the people who actually use the language just have to keep chugging.
Eh. I've been misinterpreted plenty of times by young C++ programmers when I've mentioned C. (They assume I'm really talking about C++).
I think this is a rant / a perspective everyone needs to hear once. It might be old hat and boring to people who've been programming for decades, but so long as we keep creating new programmers, we'll unfortunately need to keep reiterating this lesson.
I feel your pain. I have the same problem with people who like tool chains and design patterns that create cargo cult programmers with tonnes of baggage
There was a time in the past were it made sense though. Lots of C++ shops had just recently moved to C++ for new projects but still had plenty of existing code written in C.
> the problem is that when people say this term (C/C++) they make it seem like C and C++ are similar or closely related programming languages
Not necessarily, and even if this is true, I still do not care about what someone else’s passing opinion might be.
And in fact, if C and C++ were as this article claims they are, then they wouldn’t need to propose new special terminology for putting them together. You don’t say either “C/Java” or “C, Java” because they’re both sufficiently distinct.
I get major Linux Stallman holy war vibes from this article. C and C++ are not the same, but to call them not closely related is just completely wrong. You can basically copy paste C code and use a C++ compiler to compile it with very minor rewriting.
Writing idiomatic code in C vs C++ however is very different.
C and C++ are similar. They're technically not subset/superset, but like, 90% of the features in C are also in C++. Idiomatic C++ programming looks very different than idiomatic C programming, but most people who write C++ can write half-decent (albeit maybe not idiomatic) C; and they can learn to write idiomatic C without much of a learning curve, because the fundamentals are the same(low-level data with explicit stack/heap and memory managemnt, no guardrails, old language WATs and footguns).
C++ is radically different from C. It has classes (with plain constructors, copy constructors, destructors, visibility rules), exceptions, templates, operator overloading, move, RAII, stuff like constexpr, to name a few.
Due to the above, stuff like `{ Foo * c = a + b; }` may have a completely different interpretation in C++ than in C.
Few people would write C++ as if it were C. They would then rather write C instead.
A C++ compiler happens to include a C compiler, and allows to easily mix C++ and C code. This is just a convenience; the Zig compiler also includes a C compiler and allows to easily mix in C code, but nobody would mistake Zig for C.
Saying "C/C++" is like saying "car/aircraft", just because an F-150 and a Cessna 182 happen to include a piston engine and a seat behind it.
That’s exactly why they should not be mixed. Well written C++ 20 is easy to work with and protects you from making mistakes, while C code not only happily gives you the rope to rang yourself with—it requires you to use it! What makes C++ seem difficult today is all the things that it allows for back compat, and that those things are still how C++ is taught… by teaching “C/C++”.
I feel like if you're going to say that C and C++ are very different, there are some stronger motivating examples. Casting rules on void pointers is a tiny thing compared to general stylistic differences.
C code filled with macros being replaced by C++ classes and template instantiations makes code just on an aesthetic level look very different. RAII vs "getNewX/destroyX".
Not judging either flavor, but I think it's rare to see a file of "C/++" code and not immediately grok what you're looking at.
If you start writing a rendering engine today, using opengl or vulkan, the lib API is pure C, but that does not prevent you to have C++ code in your engine, in practice this is very common.
Eh, no. This is pedantic for the sake of pedanticness - or actually, for the sake of making a pointless argument.
There are contexts where "C/C++" makes sense, sure something like "program Foo is written in C/C++" usually doesn't make much sense (though it can make sense if it is written in both languages - i.e. using both C and C++ modules) but something like "program Foo is a C/C++ code generator" (think something like a generator for header files for example) in that the code it generates can be compiler as either C or C++. After all, unlike Rust, Go and Kotlin mentioned in the article, C and C++ do share a sizable common subset (heavily biased towards the C side of course). This is why C header files can often used as-is in C++ or with the minor modification based on the __cplusplus macro.
Language is meant to be parsed by humans, not computers and humans can take context into account (and with the recent developments in AI even computers can do that too :-P).
All jokes aside, this is just too nitpicky for me. I'm not sure if the author is personally upset that C and C++ get lumped together because they don't like C++ or something, or if they have some other gripe with the confusion, but I think it's very obvious why C and C++ get grouped together: they're... Similar and related.
The argument is "No; they're not similar! They're actually very different" and I simply reject this. Yes, they are not the same. Idiomatic C code and idiomatic C++ code are quite different. They are not compatible.
Yet, they share many concepts that basically only languages derived from C do. They aren't compatible, but mostly because they diverged over time, and it's easy to port C code to work in C++ (typically it can be done mechanically, unless you count some newer features.) Hell, is there a C++ compiler that doesn't support (some form of) C?
And while idiomatic C code and idiomatic C++ code may differ, they're not oceans apart. What really sets C++ code apart in my mind is the concepts of RAII and operator overloading. The existence of classes with inheritance may push you to code a certain way, but I think a lot of modern codebases don't even wind up using inheritance the way you might traditionally. For example, it has become common to only use inheritance for pure virtual base classes, using inheritance to implement a sort of interface composition system instead. This is also not so different from a pattern you would often see in C software where you pass a table of function pointers to implement polymorphic behaviors... In fact, it's basically the same thing.
C and C++ may feel far apart to die hard fans of only C, but it should signal something that most of the rest of the world doesn't really see it. C and C++ are definitely different, but fundamentally closer than C and C++ are to many other languages, including languages with C in the name like C#, and arguably "modern" successors like D and Go, too. (Not to mention Rust.)
I am certain that this notion does upset people because they feel it gives C a bad name, but people are always going to have misconceptions and misplaced stigma about your favorite things sometimes. Policing the way people speak is not an answer, not necessarily because there's no truth to the point that "C/C++" for example is misleading, but because there's enough truth to the point that "C/C++" makes sense to make it difficult to convince people to stop naturally associating the two.
This guy is giving off a major hall monitor vibe. If you write C in C++ it’s legal C. C++ is C with classes. That’s it, there’s overlap AND divergence between them.
> Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining and default arguments.[22]
...but that's not really true anymore. Certainly, C++ has classes, and there is a decent-sized overlap between them such that you can write code that compiles (correctly, even) in both, but each has plenty of things that isn't legal in the other, and C++ has a lot of features that C doesn't have, to the point that I suspect writing in the subset (or intersection, rather) of C and C++ results in what modern C++ devs would consider non-ergonomic, non-idiomatic code.
But for "I need something that compiles to native to frob a couple syscalls", being idiomatic matters less than remembering what compiler needs to be installed.
Most jobs I've had require some dealing with the other. Knowing the differences and how to handle the interfaces would be a requirement for either position.
I'd certainly prefer to hire someone with both tools available, to use where appropriate, not a religious ideologue obstinately refusing to consider anything that's unpure.
Kind of disingenuous to compare FFI in other languages with the fact that a lot of everyday C code can be compiled as C++ code without issue (even though C isn't strictly a proper subset of C++, in actual practice it very nearly is - no one actually writes K&R style code for example).
I do agree that they're very different, and should not be conflated (and I'm one of those programmers who will happily code C but despises coding in C++), but there is definitely a clear connection between the two, just as there is between C and Objective C.
Also, that maximumCount example in C++ is unreadable not because it's C++ code, but because the author has deliberately tried to be extra clever in writing it.
> If you’re referring to a C program or programmer just say “C”. If you’re referring to a C++ program or programmer just say “C++”. If you’re referring to both used separately say something like:
>
> C and C++
> C, C++
> C++ with C
> Etc.
>
> NOT C/C++
>
> Only if you’re using C together with C++ would it be acceptable to say C/C++.
oh ffs, stop it with the pedantry.
How long of a blog post because "c/c++" isn't "c and c++"? It's neurotic.
This article seems incredibly detached from reality. No, C++ is not just C with classes, but C and C++ are the same kind of language, with the same roots, and when we're talking to people who don't know C or C++ the difference between them is literally irrelevant because these folks are (thankfully, finally) never going to use either. The people for whom it matters know the difference, and this article is irrelevant to them, the people to whom it is completely irrelevant don't know, don't care, and don't need to hear this.
You thought you were joking, but yes, kind of like that, but then actually, given that C++ was a direct result of C.
Because JS only has the word "java" in the name because that's the name people were going to get tricked into thinking it was a serious thing over. Which is why the "real" language hassn't been called JavaScript for two decades now (but no one's going to use its real name, because ecmascript? really? do I need a cream for that?)
98 comments
[ 2.8 ms ] story [ 284 ms ] threadI think this is a rant / a perspective everyone needs to hear once. It might be old hat and boring to people who've been programming for decades, but so long as we keep creating new programmers, we'll unfortunately need to keep reiterating this lesson.
</irredeemable recalcitrant>
edit: nevermind, it's undefined behavior in both, though likely equals either 1 or 2 in C... (2 on my system) :)
I also said 'or'.
Not necessarily, and even if this is true, I still do not care about what someone else’s passing opinion might be.
And in fact, if C and C++ were as this article claims they are, then they wouldn’t need to propose new special terminology for putting them together. You don’t say either “C/Java” or “C, Java” because they’re both sufficiently distinct.
Writing idiomatic code in C vs C++ however is very different.
C and C++ evolved over time but they stayed close enough that you can relatively easily compile C code with a C++ compiler.
The few incompatibilities are historical artefacts that would probably disappear at some point if the future, for the better.
C and C++ are kind of two flavours of the same language, with different styles and paradigms.
Referring to C/C++ is talking about both styles, and yes they can be mixed and that is perfectly fine.
Due to the above, stuff like `{ Foo * c = a + b; }` may have a completely different interpretation in C++ than in C.
Few people would write C++ as if it were C. They would then rather write C instead.
A C++ compiler happens to include a C compiler, and allows to easily mix C++ and C code. This is just a convenience; the Zig compiler also includes a C compiler and allows to easily mix in C code, but nobody would mistake Zig for C.
Saying "C/C++" is like saying "car/aircraft", just because an F-150 and a Cessna 182 happen to include a piston engine and a seat behind it.
C code filled with macros being replaced by C++ classes and template instantiations makes code just on an aesthetic level look very different. RAII vs "getNewX/destroyX".
Not judging either flavor, but I think it's rare to see a file of "C/++" code and not immediately grok what you're looking at.
People are using C/C++, this is a thing.
There are contexts where "C/C++" makes sense, sure something like "program Foo is written in C/C++" usually doesn't make much sense (though it can make sense if it is written in both languages - i.e. using both C and C++ modules) but something like "program Foo is a C/C++ code generator" (think something like a generator for header files for example) in that the code it generates can be compiler as either C or C++. After all, unlike Rust, Go and Kotlin mentioned in the article, C and C++ do share a sizable common subset (heavily biased towards the C side of course). This is why C header files can often used as-is in C++ or with the minor modification based on the __cplusplus macro.
Language is meant to be parsed by humans, not computers and humans can take context into account (and with the recent developments in AI even computers can do that too :-P).
All jokes aside, this is just too nitpicky for me. I'm not sure if the author is personally upset that C and C++ get lumped together because they don't like C++ or something, or if they have some other gripe with the confusion, but I think it's very obvious why C and C++ get grouped together: they're... Similar and related.
The argument is "No; they're not similar! They're actually very different" and I simply reject this. Yes, they are not the same. Idiomatic C code and idiomatic C++ code are quite different. They are not compatible.
Yet, they share many concepts that basically only languages derived from C do. They aren't compatible, but mostly because they diverged over time, and it's easy to port C code to work in C++ (typically it can be done mechanically, unless you count some newer features.) Hell, is there a C++ compiler that doesn't support (some form of) C?
And while idiomatic C code and idiomatic C++ code may differ, they're not oceans apart. What really sets C++ code apart in my mind is the concepts of RAII and operator overloading. The existence of classes with inheritance may push you to code a certain way, but I think a lot of modern codebases don't even wind up using inheritance the way you might traditionally. For example, it has become common to only use inheritance for pure virtual base classes, using inheritance to implement a sort of interface composition system instead. This is also not so different from a pattern you would often see in C software where you pass a table of function pointers to implement polymorphic behaviors... In fact, it's basically the same thing.
C and C++ may feel far apart to die hard fans of only C, but it should signal something that most of the rest of the world doesn't really see it. C and C++ are definitely different, but fundamentally closer than C and C++ are to many other languages, including languages with C in the name like C#, and arguably "modern" successors like D and Go, too. (Not to mention Rust.)
I am certain that this notion does upset people because they feel it gives C a bad name, but people are always going to have misconceptions and misplaced stigma about your favorite things sometimes. Policing the way people speak is not an answer, not necessarily because there's no truth to the point that "C/C++" for example is misleading, but because there's enough truth to the point that "C/C++" makes sense to make it difficult to convince people to stop naturally associating the two.
There is legal C that is legal C++ but has different observable behaviour
And if you're "writing C in C++" then you're not really using C++ as it was intended, might as well just write C and use a C compiler.
Well it was, once upon a time; as https://en.wikipedia.org/wiki/C%2B%2B puts it,
> Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining and default arguments.[22]
...but that's not really true anymore. Certainly, C++ has classes, and there is a decent-sized overlap between them such that you can write code that compiles (correctly, even) in both, but each has plenty of things that isn't legal in the other, and C++ has a lot of features that C doesn't have, to the point that I suspect writing in the subset (or intersection, rather) of C and C++ results in what modern C++ devs would consider non-ergonomic, non-idiomatic code.
But for "I need something that compiles to native to frob a couple syscalls", being idiomatic matters less than remembering what compiler needs to be installed.
I would entertain a job that involved C development but I would be very hesitant to to entertain one for C++
I'd certainly prefer to hire someone with both tools available, to use where appropriate, not a religious ideologue obstinately refusing to consider anything that's unpure.
And I never seen that you can mix Go/Java/... and C Syntax/standard lib in one file.
What a BS...
I do agree that they're very different, and should not be conflated (and I'm one of those programmers who will happily code C but despises coding in C++), but there is definitely a clear connection between the two, just as there is between C and Objective C.
Also, that maximumCount example in C++ is unreadable not because it's C++ code, but because the author has deliberately tried to be extra clever in writing it.
>
> C and C++
> C, C++
> C++ with C
> Etc.
>
> NOT C/C++
>
> Only if you’re using C together with C++ would it be acceptable to say C/C++.
oh ffs, stop it with the pedantry.
How long of a blog post because "c/c++" isn't "c and c++"? It's neurotic.
Because JS only has the word "java" in the name because that's the name people were going to get tricked into thinking it was a serious thing over. Which is why the "real" language hassn't been called JavaScript for two decades now (but no one's going to use its real name, because ecmascript? really? do I need a cream for that?)
After several years of production programming... you will see the languages are not mutually exclusive:
https://www.youtube.com/watch?v=sFacWGBJ_cs