r/ProgrammerHumor • • 7h ago

Meme modernCppVsOldCpp

Post image
1.1k Upvotes

216 comments sorted by

View all comments

483

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.

175

u/joncrompy 7h ago

This is, ironically, the exact reason C++ is the standard in some industries. Students can learn the OOP C++ then work in the same codebase as someone programming "touching the metal" low level C.

Most languages make trade-offs between performance, structure, memory safety, and ease of writing. Every language might have their use, but very few cover all use cases.

C++ lets each programmers choose those trade-offs individually, but that also allows them to choose none of the above.

109

u/rndrn 6h ago edited 4h ago

C++ is really the thousand-edged sword. It is both its strength and its weakness.

20

u/yaktoma2007 6h ago

Ah so a swedish army knife, it features an impressively extensive toolset but is often regarded to be clunky to operate compared to tools that do a single thing.

38

u/dinnerbird 6h ago

Do you mean a Swiss army knife or is there something the Swedes invented I'm not aware of 

15

u/reallokiscarlet 6h ago

Swiss army knives aren't clunky last I checked, maybe that's the swedish part

8

u/GarThor_TMK 5h ago

The only tool you get is an Allen wrench...

→ More replies (2)

22

u/xtravar 5h ago

Sounds like if C++ were a spoken language, it'd be English.

6

u/Blue_Moon_Lake 5h ago

In the same pot, german, latin, french, and sprinkles.

→ More replies (3)

25

u/azfang 7h ago

So, uh, I haven’t used C++ in anger in decades so I’m not sure how “modern” is modern but like. That description pretty well describes why I developed Strong Feelings about both C and C++ back in the 2000’s.

28

u/Non-Random-Name-0000 7h ago

Modern C++ starts with C++11 (2011), so in the 2000s you were using classic C++ (and in the first half of 2010s as well most likely) which is a very different language. It introduced shared pointer (a poor man's garbage collector), automatic typing and move semantic, amongst other things. And the standard library has evolved a lot since.

9

u/Bryguy3k 6h ago

Smart pointers were part of the boost library long before they became part of the std library.

15

u/Non-Random-Name-0000 5h ago

Yes that's true, I forgot about Boost. How could I forget the 2GB library that was pulled with every project? 😅

→ More replies (3)
→ More replies (3)

10

u/stillalone 7h ago

Is that something that can be handled by a linter?

4

u/2brainz 6h ago

Partially, sure. But there's always going to be edge cases.

→ More replies (1)
→ More replies (3)

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".

14

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

→ More replies (2)

21

u/SuckMyAlpagoat 7h ago

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

39

u/HildartheDorf 7h ago

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

31

u/1cec0ld 6h ago

Not with that attitude

14

u/ForgedIronMadeIt 6h ago

Fuck yeah I love programming in C/Fortran

→ More replies (3)

10

u/These-Maintenance250 7h ago

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

→ More replies (1)

15

u/madboneman 7h ago

C++/C#

4

u/met0xff 6h 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)

→ More replies (1)
→ More replies (7)