Re:Java Was Strongly Influenced by Objective-C
by MereInterest on Thursday June 25, 2015 @07:32AM
(#9777142)
Sure, it does. In C++, you can declare everything on the heap, then pass pointers by value. In Java, you declare everything on the heap (because you can't declare it anywhere else), then pass pointers by value (because you can't pass classes in any other way).
The only difference is that Java's subset also does not include pointer arithmetic, so this is actually a safe coding practice, because it allows for garbage collection to be performed.
Re:Java Was Strongly Influenced by Objective-C
by wfunction on Thursday June 25, 2015 @03:10PM
(#9780224)
You're not countering the same claim I'm making.
Yes, C++ can emulate what Java is doing, but no, that's not what I'm saying. I'm saying C++ classes are not reference types, i.e., every class you define is always a value type, which is the exact opposite of Java. Obviously C++ also has pointers/references that could help you emulate Java, but that's beside the point. The point is that classes work differently in C++ and Java, and neither functionality is a subset of the other.
Re:Java Was Strongly Influenced by Objective-C
by MereInterest on Friday June 26, 2015 @09:51AM
(#9784295)
I suppose I'm not seeing the difference between Java's restriction of only using reference semantics, and C++'s option of using reference semantics. Since Java only provides reference semantics, while C++ allows both reference semantics and value semantics, this would make Java be a subset of C++, in this regard.
Re:Java Was Strongly Influenced by Objective-C
by vbezhenar on Thursday June 25, 2015 @09:28AM
(#9777679)
You can always declare something like:
class MyClass_ { ... }
typedef MyClass_ *MyClass;
and you have identical "reference" semantics in C++. Of course you have to use `->` instead of `.`, but does it matter?
Not sure where you got that from... the notion of a class being a "reference type", which is the foundation of Java, doesn't even exist in C++. Every class type is a value type in C++.