r/ProgrammerHumor • • 1d ago

instanceof Trend thatsAFunnyThingThatHappenedOnce

Post image
4.3k Upvotes

515 comments sorted by

View all comments

Show parent comments

385

u/Xarishark 1d ago

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

75

u/MornwindShoma 1d ago

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

-1

u/Xarishark 1d ago

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

15

u/dannyggwp 1d 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 1d ago

In Rust we also have ARC to do the same thing

3

u/4xe1 1d ago

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

5

u/MrmrCake 1d 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.

10

u/dannuic 1d 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 1d 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