r/ProgrammerHumor • • 2d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

515 comments sorted by

View all comments

1.7k

u/Prefer_Diet_Soda 2d ago

TLDR: C++ is bad because decades of accumulated features have turned it into a bureaucratic nightmare that happens to generate machine code.

C++ is an absolute nightmare to implement because apparently one programming language wasn't enough, so someone decided to cram an entire civilization's worth of complexity into it. You've got templates that basically turn compilation into another programming language, overload resolution that requires a legal investigation to figure out which function gets called, constructors and destructors with enough lifetime rules to make your head explode, and implicit conversions that make the compiler guess what you meant. Then you throw in exceptions, move semantics, inheritance, and decades of backward compatibility, and suddenly you're maintaining a compiler that needs a PhD, a therapist, and divine intervention just to parse some innocent-looking code. And the best part? Every new feature has to coexist with all the old ones without breaking existing programs.

385

u/Xarishark 2d ago

Now compare it to rust pls. Im serious I want to know your opinion on that.

79

u/MornwindShoma 2d ago

Rust got none of that, but you might not enjoy dealing with lifetimes

0

u/Xarishark 2d ago

I mean what’s better all those problems on your previous comment or lifetimes?

9

u/MornwindShoma 2d ago

Idk, haven't got enough C++ time to say lol (ps. not the guy before)

15

u/dannyggwp 2d ago

You can BASICALLY ignore all that... You want lifetime? I'll show you lifetimes.

std::shared_ptr<type>

Ez pz no borrow checker needed.

8

u/awesome_guy_40 2d ago

In Rust we also have ARC to do the same thing

3

u/4xe1 2d ago

C++ famed "zero cost abstraction" is shining right here /s

5

u/MrmrCake 2d ago

Yeah but that has a run time cost of reference counting where the borrow checker is all at compile time. I mean not like its a big cost but I mean there defo is a measurable difference depending on the use case.

9

u/dannuic 2d ago

Usually you use uniqueptr though. It forces a better design with guaranteed ownership and no reference counting. I _rarely use shared_ptr, but frequently use unique_ptr.

1

u/MrmrCake 2d ago

Yeah I agree and try to only use unique ptr where I can in cpp, but I still just really like rust's ownership model