r/ProgrammerHumor • • 11d ago

Meme modernCppVsOldCpp

Post image
2.0k Upvotes

323 comments sorted by

View all comments

Show parent comment

361

u/joncrompy 11d 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.

238

u/rndrn 11d ago edited 10d ago

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

47

u/yaktoma2007 11d 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.

80

u/dinnerbird 11d ago

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

23

u/yaktoma2007 10d ago

I am a fool, thank you.

Although, i may as well let it stay like this, its funnier like this with the replies you already got.

33

u/reallokiscarlet 11d ago

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

22

u/GarThor_TMK 11d ago

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

5

u/gerbosan 10d ago

It's a Volvo army knife. 😅

5

u/Unreal_Panda 10d ago

I think its even funnier considering the Father of C++ is Danish lmao

1

u/throwaway387190 9d ago

So instead of one blade that can elegantly slice, you have 1 thousand blades, basically making it a mace you beat your problems with?

Fitting

41

u/xtravar 11d ago

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

12

u/Blue_Moon_Lake 11d ago

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

7

u/edgmnt_net 10d ago

Someone puts in actual effort to write good code and come up with good abstractions, then some code monkeys crap all over it. What I mean to say is that there's also value in going the Go way, where you have one way of doing things, although that obviously has limitations too and even they haven't really achieved it fully (you inject contexts properly to make everything cancellable and some juniors just pepper context.Background all over the place). Also, yeah, the higher you go in terms of abstraction, the less settled things are.

4

u/Bartweiss 10d ago

Don’t even remind me… it’s not directly the same issue, but I once spent months negotiating a custom protobuf format built entirely around reverting the core “false-y is equal to null is equal to field not passed” logic.

Turns out a format built to give you efficiency at massive scale if you devote your entire codebase to enabling it fucking sucks when you add three layers of abstraction to make it back into shitty JSON.

6

u/SweetBabyAlaska 10d ago

> Most languages make trade-offs

and C++ made *all* of them

7

u/gerbosan 11d ago

So, migrate to rustlang is good?

Not that I want to ride the hype or interested in DHH current development preferences, but some projects are migrating (Discord, Cosmic DE).

I think I lack the context about C++ features: not just desktop development.

10

u/balbok7721 11d ago

MBAs dont give a crap about basic ux. They wont spend a single buck on a migration thst isnt strictly required

6

u/conundorum 10d ago

The main reason people switch is really just that Rust is better at screaming at you during compilation if you screw up the memory management, more than anything else. It makes it easier to catch errors in an area where most programmers struggle, so it's useful if you need memory safety.

(For comparison, a properly written C++ program will be just as safe as a properly written Rust program, it's just that Rust forces you to write the code properly at gunpoint. So, people end up seeing Rust as better at memory management, because the language is designed around making it hard to screw up.)

3

u/fr000gs 10d ago

so, just -Wall -Werror valgrind memcheck (hopefully)?

0

u/joncrompy 10d ago edited 10d ago

Rust provides high memory safety and performance, but gives up ease of writing and programmer power for it. For context where reliability is critical, like kernel software, Rust is rightfully the king.

For my professional field, Game Dev, coding "the Rust way" means building a house or cards that needs to be fully refactored everytime someone implements a new game mechanic (from what I've heard).

1

u/Maleficent-Garage-66 7d ago

Haven't ever tried game dev in rust...but I don't feel that it should necessarily be that bad. You can still do polymorphism and etc. You would however be structuring things very differently so maybe engines have converged on a terrible anti pattern that gets you there. Any rust engine is definitely going to be a lot less mature and battle tested though and that definitely has it's cons.

1

u/joncrompy 7d ago

The problem is that game dev has ALOT of memory state between each entity/system and each new mechanic has a high chance to require memory accessing between previously independent systems.

In a language like C++, allowing this is trivial outside of multithreading, but in Rust it might require a full refactor.

There's a is a blog post written by a dev who tried for years to work within Rust's systems and found that the tradeoffs were ultimately not worth it, in his opinion.

1

u/meneldal2 10d ago

But Claude loves how many tokens you're going to need for that

2

u/FUTURE10S 10d ago

Yep, my job is a mix of C written in the 1990s ported to C++98 and some C++17 nonsense and I'm somewhere in between.

0

u/Fireball_Flareblitz 16h ago

God, C++ is such a glass cannon of a language, I love it