3 ms·
I assume you mean ref counted smart pointers, not all smart pointers are ref counted. Java's pointer might be faster than shared_ptr. But, in Java, all objects
by vinkelhake 13y ago
I assume you mean ref counted smart pointers, not all smart pointers are ref counted.
Java's pointer might be faster than shared_ptr. But, in Java, all objects are held by pointers. C++ gives you more options. It's not like we're going "Damn, I just can't figure out the ownership here. I'll just use shared_ptr and be done with it" every day. In my experience, usage of shared_ptr is quite limited.
- pkolaczk 13y agoIt is definitely going to change at some time, IBM already has a prototype of JVM supporting object packing and fine-grained alignment control. shared_ptr use is limited because shared_ptr is slow and people learned to avoid it at all cost. But having to think about ownership influences design choices and often makes things more complex and less performant that needed (e.g. it often forces to copy objects instead to just pass a pointer).
- vinkelhake 13y agoThinking about ownership is something that is natural for C++ programmers and will naturally affect design choices. We (C++ programmers) don't avoid shared_ptr at all costs and the primary reason for avoid it is because it muddles ownership semantics. In other words: if a magical zero-cost shared_ptr implementation appeared, we wouldn't start using it everywhere. You can keep extolling the virtues of Java performance, but fact remains that Java doesn't see much use in areas where performance is critical. It doesn't mean Java doesn't have a use, it's just not there.
- pkolaczk 13y ago> Thinking about ownership is something that is natural for C++ programmers and will naturally affect design choices Maybe this is the reason C++ guys always complicate things: http://www.johndcook.com/blog/2011/06/14/why-do-c-folks-make-things-so-complicated/ http://www.johndcook.com/blog/2011/06/14/why-do-c-folks-make... As of Java being not-performant enough: that's why Java is used as one of the most popular language for implementation of modern NoSQL databases systems. Everyone knows performance doesn't matter in databases. ;)