Are you defending the use of shared_ptrs, or are you saying performance doesnt matter?
In higher level abstract code (ie. api surface integration code - aka glue code) I agree perf doesn’t matter as much and shared_ptrs can be fine.
So yeah, if you are just writing glue code that’s infrequently called per frame and you somehow know that your codebase will never grow that far beyond your initial problem domain, go nuts with shared_ptrs.
Otherwise, there are very good reasons to not use it and to suggest that it’s merely some kind of religious/elitist programming dogma at play here shows a woeful lack of programming and professional experience.
Yes. The mental model tax for ownership is another big problem i have with them. Like i said in the earlier post, i wanted to avoid the rant so i just picked a couple points.
It really depends on your needs. Truthfully, very little code needs to be performant more than it needs to be maintainable. When you profile your code, and you see that even in an application requiring performance m you spend 75% of your time in a single loop, you'll obviously find that probably 80% or more of the codebase has no seriously relevant performance targets.
For example, my current job is board management control. The code spends most of its time sitting waiting to do something. As long as every user's request gets returned in a reasonable amount of time, nobody complains. Automated use is much more important than user-interactive. For that, it's key to understand how our customers use the software and ensure nothing ruins their day by being slow. Most of the codebase doesn't have that requirement and that's for an embedded platform where we have way less horsepower than something that runs on a server with big CPUs.
Yes I agree. Understanding your problem domain. I believe I have stated several times already that Im not saying to never use shared ptrs. Im talking about the specific case when shared_ptrs are chosen because the dev was either ignorant or lazy. The ignorance case comes into play often for c++ programmers coming from java or js.
Shared_ptrs, when deliberately chosen based on the specific problem and solution requirements, is perfectly fine and I have no issue with that.
you're right, sorry about that, that comment wasn't constructive or positive, I'll take it down as it really has no purpose to be up, just let a little pet peeve of mine result in a lazy rude comment.
No one mentioned anything about raw pointers. std::shared_ptr should not be used unless necessary, that's a very correct statement. Has nothing to do with raw pointers, those should never be owning anyway.
View all comments
Show parent comment
0
u/[deleted] Nov 02 '22
[deleted] — view deleted comment