1060
C++ (lemmy.zip)
you are viewing a single comment's thread
view the rest of the comments
[-] xmunk@sh.itjust.works 79 points 3 weeks ago

This graph cuts off early. Once you learn that pointers are a trap for noobs that you should avoid outside really specific circumstances the line crosses zero and goes back into normal land.

[-] lazyneet@programming.dev 16 points 3 weeks ago

I've been using C++ almost daily for the past 7 years and I haven't found a use for shared_ptr, unique_ptr, etc. At what point does one stop being a noob?

[-] AngryPancake@sh.itjust.works 26 points 3 weeks ago

Given that you probably are using pointers, and occasionally you are allocating memory, smart pointers handle deallocation for you. And yes, you can do it yourself but it is prone to errors and maybe sometimes you forget a case and memory doesn't get deallocated and suddenly there is a leak in the program.

When you're there, shared_ptr is used when you want to store the pointer in multiple locations, unique_ptr when you only want to have one instance of the pointer (you can move it around though).

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

[-] arendjr@programming.dev 7 points 3 weeks ago

Smart pointers are really really nice, I do recommend getting used to them (and all other features from c++11 forward).

You’re recommending him to give up his sanity and/or life?

[-] porgamrer@programming.dev 2 points 3 weeks ago

I would have said the same thing a few years ago, but after writing C++ professionally for a while I have to grudgingly admit that most of the new features are very useful for writing simpler code.

A few are still infuriating though, and I still consider the language an abomination. It has too many awful legacy problems that can never be fixed.

load more comments (13 replies)
load more comments (40 replies)
this post was submitted on 08 Jun 2024
1060 points (98.5% liked)

Programmer Humor

18253 readers
1 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS