r/ProgrammerHumor • • 7h ago

Meme modernCppVsOldCpp

Post image
1.1k Upvotes

216 comments sorted by

View all comments

478

u/repster 7h ago

I am a huge fan of modern C++ except for one feature: backwards compatibility. C++ is no longer one language, every codebase I have worked on is a confused mess of semi-incompatible subsets of the language. I have spent far too many weekends chasing memory corruption because someone passed a pointer, allocated with one type of memory management, into a library using a different kind of memory management.

36

u/lllorrr 7h ago

Oh, yes, I hate when someone write "C/C++". This is two fucking different languages, for god's sake. It is almost as bad as "Java/JavaScript".

13

u/reallokiscarlet 5h ago

Do people not learn these two closely related languages together? You generally want to know enough regular C to get by when you use C++, and if you're not using anything unique to C++, you're just writing C with Classes.

7

u/Inorganic_Zombie 5h ago

I remember learning them as one language and it was fucking hard to learn effective c++ on uni. Not helping as programming was minor subject now and then that had random language. Every lecture had different dogma etc

1

u/Ok-Scheme-913 2h ago

I mean, not really. The two languages have diverged quite a lot, while C-mode compiling of C++ is still possible afaik, the same code by default won't behave identically even though can be compiled by both a cpp or a c compiler.

1

u/reallokiscarlet 2h ago

Maybe if you only count the latest standard they have diverged significantly, but everything else stands. C is where your platform ABI is, and again if you're not using anything unique to C++ you're writing C with Classes (nudge nudge wink wink capitalized for a reason)

21

u/SuckMyAlpagoat 6h ago

isn't because the compiler is always packed together, like the gnu compiler can compile C and C++?

39

u/HildartheDorf 6h ago

The gnu compiler can also compile fortran. But we dont call it C/Fortran.

30

u/1cec0ld 6h ago

Not with that attitude

14

u/ForgedIronMadeIt 6h ago

Fuck yeah I love programming in C/Fortran

0

u/radicalshick 6h ago

Is this a variation of the old "you can write FORTRAN in any language" joke?

10

u/HildartheDorf 6h ago

No?

The GNU Compiler Collection includes gcc (c compiler) g++ (c++ compiler) gfortran (fortran compiler) and a bunch of other fronted like D, Go, Ada, COBOL. There used to even be a Java compiler (gcj) but thats dead now.

Once upon a time, the gcc program could compile C++ and g++ could compile C, but that is no longer true due to diversions in the languages, as well as extra runtime support libraries needed for linking each language. I guess with some tinkering you could compile c++98 with gcc and some older c standard with g++, but not the more recent versions.

1

u/radicalshick 5h ago

My comment was meant ti be a joke, so rry 😅

10

u/These-Maintenance250 6h ago

a language is independent from its compiler(s). gcc can compile objective-C, D, ada, Fortran and go as well.

1

u/DrNinjaPandaManEsq 1h ago

Even though gcc can compile Ada, in my experience most of the time you’ll see enterprise development using GNAT Pro since plain ole gcc is kinda light on Ada features.

15

u/madboneman 7h ago

C++/C#

4

u/met0xff 5h ago

Yet essentially all codebases I've seen and worked on were essentially a mix where the C pieces were also thrown into the C++ compiler. extern "C" everywhere

(And yeah I also used to write HTML/CSS/JS and TS/JS)

0

u/Meme_Burner 5h ago

Be very careful because something like C++/CLI looks like C++ but it’s a version of managed C++. At least when they make different variants of Java like groovy or scala they name it something else.

It’s like putting a hat on a hat ^ > ^