> Once I saw this guy on a bridge about to jump. I said, "Don't do it!" He said, "Nobody loves me." I said, "God loves you. Do you believe in God?"
> He said, "Yes." I said, "Are you a Christian or a Jew?" He said, "A Christian." I said, "Me, too! Protestant or Catholic?" He said, "Protestant." I said, "Me, too! What franchise?" He said, "Baptist." I said, "Me, too! Northern Baptist or Southern Baptist?" He said, "Northern Baptist." I said, "Me, too! Northern Conservative Baptist or Northern Liberal Baptist?"
> He said, "Northern Conservative Baptist." I said, "Me, too! Northern Conservative Baptist Great Lakes Region, or Northern Conservative Baptist Eastern Region?" He said, "Northern Conservative Baptist Great Lakes Region." I said, "Me, too!"
> Northern Conservative†Baptist Great Lakes Region Council of 1879, or Northern Conservative Baptist Great Lakes Region Council of 1912?" He said, "Northern Conservative Baptist Great Lakes Region Council of 1912." I said, "Die, heretic!" And I pushed him over.
It's funny, but many Baptists don't consider themselves Protestant.
In context of The Famous Article, if Judaism = ALGOL, C = Catholism and C++ = Protestantism, then (at least some) Baptists have a Pascal attitude, never having bought off on Rome enough to protest against it.
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.
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.
> Another big incompatibility with C and C++ is that C++ is actually incompatible with K&R syntax
Why in the world would you use K&R syntax to demonstrate the differences between C and C++? Some of the most readable C code I've looked at has to be Sean Barett's single header files. And he sure doesn't use K&R syntax, and for good reason. Why not show something much simpler? Like the fact that you don't need to typedef a struct to use it without adding the structure keyword to the type like you do in C?
> Lots of Suckless users and developers only use C and POSIX shell in their programs. Cat-v endorses C and C-like languages, but despises C++. Even Linus Torvalds, the creator Linux and Git, won’t touch C++. Heck, even I love C but I can’t stand programming in C++
Ok man, you can gatekeep all you want. You know what's funny? Games are probably one of the quintessential examples of software that requires the performance of C or C++. And you know what the most sold game of all time is? Oh yea, Minecraft, written in Java. I'm sure that makes you shudder. And you know what? I'm glad Notch didn't listen to a bunch of gatekeepers and wrote it in a language he knew and could use and blessed the world with this amazing game.
Also, some people just don't hate themselves. They're not too hard core to realize that C has some very real flaws, but may still appreciate the simplicity of C. Those programmers may program in C++ in a style very close to C, but with the additional benefit of generic programming for type safe containers instead of a bunch of hideous macro magic that's bound to bite you in the ass very quickly. And you know what? There's nothing wrong with that either.
The funny thing is, I agree with the title of this article, but the whole tone is just gross. I'm so sick of gatekeepers ruining programming for newcomers and old timers alike. In the true spirit of being a hacker, quit being so anal and let people just code and kindly correct them if they spread a misnomer like the idea that C and C++ are 100% equivalent.
It also looks like it's been deprecated since C89 and the use of the style has also been discouraged since then according to this article[0].
> At the time, they felt they could not remove the K&R “old-style” definitions. It had not been deprecated long enough, and the new syntax had not been around for long enough (it hadn’t been around at all, in fact). So, they rolled it into C89 deprecated, and explicitly discouraged its use for some 33+ years.
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.
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).
> 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.
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.
I'm similarly irked when people say "C/C++" and I would prefer that people not confuse the two. I used to say "C/C++" before I gained sufficient knowledge to understand the differences between the two languages, so if you say "C/C++" I know you're not an expert in either.
Admittedly, the author did a phenomenally poor job at highlighting the differences that people should care about. Nobody cares about casting malloc or K&R syntax. People do care about compilation time, binary size, strong type systems, name mangling, debugging, complexity, error messages, embedding etc.
Technical discussion aside, I'm saddened by the dismissive nature of the comments. Even if you're not at a point where you can internalize why someone else is asking to stop saying "C/C++", the unempathetic nature of the comments is discouraging.
I can see that happening, and I would frame it as a choice rather than absolute truths, i.e. "this set of strengths of C" vs "this other set of stregths of C++". Imo the sets are disjoint enough that "C/C++" is doing the users of both languages a disservice, but convincingnothers of this does require a better essay.
> 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.
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.
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.
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 probably someone who is going to say, “Well you can write C code in a C++ program, so technically C is a subset of C++.” The only problem is that you can write C code in Zig, Go, Nim, and basically almost every other language out there has a C FFI! So should I refer to Zig, Go, and Nim as C/Zig, C/Go, and C/Nim? Obviously no.
I'm sympathetic to the overall view here (not sure I agree, just that I understand it), but this a terrible argument. People say that you can write C code in a C++ program because it doesn't need FFI. You just write in the shared subset that is legal C and legal C++, and then - and this is kind of the point - you feed it into either compiler and it works.
I would hear this complaint in C communities for decades. I think it says something about how little people are writing C and C++ these days that so much of this thread thinks it's a bad take.
Granted, I don't think this piece of writing makes the argument as well as it could.
> For as long as I can remember, I have heard people say C/C++ when referring to a project written in C and or C++. A lot of programming/developer jobs also refer to C/C++ when they need a programmer who knows either C or C++. To most people who have never touched C or C++ this might not seem like a big deal. However, 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. That is not true.
The post answers itself right off the top. They're close enough that finding someone with experience in either is potentially qualified to be considered for a role.
For someone who specializes in only C or C++, they're very different. In the context of programming languages on the whole, experience in one often means a lot of context to using the other.
If you have a problem with "C/C++", I'd even have a problem with saying C++ since usages can vary so widely. I learned K&R C, then some MSVC++ with MFC/ActiveX/COM, some OS/2 SOM/IDL C++, then more ANSI C and later C++. But now the modern C++ I sometimes see is quite different. No one uses all new features but if they did, it seems like a different language. We still call it all C++. And to me C is still an improper subset.
Edit: I also sometimes write F#/OCaml, is that wrong? Depends on the context.
The biggest difference is the mindset. C++ is a complex language whereas C is relatively simple. This greatly impacts the audiences and culture both languages attract.
Very good points. Comment on your website: please consider changing your design from white text on black background. This is very hard/uncomfortable for people with moderate to severe astigmatism (like myself) to read. I had to quickly switch to reader mode to avoid feeling sick when looking at the site. If you like the vibes of dark backgrounds, maybe try a medium dark grey? Thanks again for the helpful writeup.
There might be good arguments for avoiding "C/C++" but this article makes none of them. If the author is going to be playing the "modern C++ isn't anything like when it started out" card then they damn sure shouldn't be talking about K&R declaration style either. Using FFI in Rust/Go whatever is not at all the same thing as a compiler directly accepting much of the same code without distinction. Arguments about constructors/destructors and overloading and lambdas and move semantics would be at least slightly more compelling, but all are absent. It's not clear the author even knows C++ very well. Net result is that some people will keep using "C/C++" solely to poke fun at the ultra-pedantic and needlessly aggrieved.
I can write code in C and consume it in C++ (through extern "C").
I can write code in C++ and consume it in C (through extern "C" again).
C and C++ each have their own language idioms, just like other programming languages have their own.
There are usecases where you want to reuse code written in one language from within another. The evolution of C++ took a pragmatic look at this and provided mechanisms for that. If you are not using C++ or don't have that use case, that is fine. But language choice depends on a lot of other factors other than just pedantry.
I'm still maintaining C++ compact in my pure C projects, just because the C++ compiler is soo much better finding opportunities and errors. C analysis is just too loose.
and that he knows a thing or two about pointer arithmetic.
still C and C++ have a totally different approach to program design: A C project of non trivial size will have lots of insane tricks with macros and callback functions, whereas C++ has entirely different methods of abstraction.
I think that's a very significant difference.
Also C++ has this std::unique_ptr<> thing that helps a lot with preventing memory leaks. And C++ has stl, so you won't have to write your own list/array/map abstractions.
I came across a lecturer at my University talking about the C++ course he'd been giving. The students had been struggling and so he'd cut back the expected material a little. I remember him saying afterwards "I taught the 'C' but didn't get to the '++'". Surely not the person you want teaching scientific computing to undergraduates.
C and C++ are very different from a C/C++ (ha !) programmer's point of view, but from a more general "computer scientist" point of view they are nearly the same: AoT compiled language, no garbage collection, typed, fast, and with looots of ways to shoot yourself in the foot (Undefined Behavior everywhere).
In contexts like "how do I do this thing in C/C++?", it means the common subset of C and C++, and that's so big that that's a very appropriate use. Consider that the entirety of the official Lua implementation is written that way.
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
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.
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++”.
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?)
Ever since I became aware of the backlash associated with saying "C/C++", I try to use it everywhere. Not because I don't understand the points, nor because I disagree with them.
Baiting pedants is fun, basically. They always go off and 95% of everybody does an eye-roll. Then I point out that there is a very significant subset of C that is also a subset of C++ and it's actually a very good and useful subset that we mostly always program in. And we could call that, very large, subset of C, C/C++. HAHAHAHAHA!
in discussions outside of C or C++ projects and especially when talking about memory safety or higher level concepts it's completely fine to call it C/C++, the distinction is just noise to a completely different conversation being had
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.
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.
> He said, "Yes." I said, "Are you a Christian or a Jew?" He said, "A Christian." I said, "Me, too! Protestant or Catholic?" He said, "Protestant." I said, "Me, too! What franchise?" He said, "Baptist." I said, "Me, too! Northern Baptist or Southern Baptist?" He said, "Northern Baptist." I said, "Me, too! Northern Conservative Baptist or Northern Liberal Baptist?"
> He said, "Northern Conservative Baptist." I said, "Me, too! Northern Conservative Baptist Great Lakes Region, or Northern Conservative Baptist Eastern Region?" He said, "Northern Conservative Baptist Great Lakes Region." I said, "Me, too!"
> Northern Conservative†Baptist Great Lakes Region Council of 1879, or Northern Conservative Baptist Great Lakes Region Council of 1912?" He said, "Northern Conservative Baptist Great Lakes Region Council of 1912." I said, "Die, heretic!" And I pushed him over.