Earlier quoted context omitted.
There are. Think about classloaders and the whole dynamic code loading thing. Every single object has a class object associated with it.
But can you pass classes around as objects after they're loaded? Do they have a value beyond their identifier?
Java Was Strongly Influenced by Objective-C
41–50 of 53 posts
Re: Java Was Strongly Influenced by Objective-C
#42Earlier quoted context omitted.
// unseen? if (foo.getClass() instanceof someClassObject) ...
In this case isn't someClassObject just a literal that's resolved at compile-time and erased into a simple identifier symbol? You can't pass someClassObject as an argument to anything but an operator like new or instanceof , and you can't assign to or from it, it doesn't itself belong to a class. It isn't an object.
No. Its a variable assigned in runtime.
public void yesYouCan (Object foo, Class someClassObject) {
// compile time?
if(foo.getClass() instanceof someClassObject) { ... }
}
Regardless, class and symbolic resolution occur at both compilation (to create the binary clsss files) and in runtime in the JVM (to load and execute the binary generated by the compiler):http://java.sun.com/docs/books/jls/second_edition/html/execu...
> You can't pass someClassObject as an argument to anything but an operator like new or instanceof, and you can't assign to or from it, it doesn't itself belong to a class. It isn't an object.
No, its quite possible/common to write methods that take class objects as parameters.
Re: Java Was Strongly Influenced by Objective-C
#43Earlier quoted context omitted.
There are. Think about classloaders and the whole dynamic code loading thing. Every single object has a class object associated with it.
But can you pass classes around as objects after they're loaded? Do they have a value beyond their identifier?
In Java's type system, classes are 'first class objects':
Re: Java Was Strongly Influenced by Objective-C
#44Re: Java Was Strongly Influenced by Objective-C
#45Earlier quoted context omitted.
Sure you can ... object.sendMessage(messageName) ;) Or for already built classes ... see java.lang.reflect.Method Personally if I were to choose, I'd trade some syntactic sugar for a decent garbage-collector. But that's just me :)
Objective C 2.0's garbage collector works just fine tyvm
Re: Java Was Strongly Influenced by Objective-C
#46Earlier quoted context omitted.
Sure you can ... object.sendMessage(messageName) ;) Or for already built classes ... see java.lang.reflect.Method Personally if I were to choose, I'd trade some syntactic sugar for a decent garbage-collector. But that's just me :)
Message forwarding is not syntactic sugar!
However, people associate "syntactic sugar" with a connotation of not being a significant difference. Many very useful tools in programming are merely syntactic sugar. For, while, and similar control flow structures are just syntactic sugar over either continuations or gotos.
Message passing OO is syntactic sugar. As evidence, look at the object system the Gtk folks made for themselves in C, or the various object systems Perl programmers have made for themselves.
The example of object systems in Perl illustrates another point about syntactic sugar: having a language which makes it possible for programmers to add their own syntactic sugar within the language is incredibly powerful. Moose is a great system, and Perl's flexible syntax is what makes it possible(although I don't really know Perl well enough to know how it's implemented, its syntax is very pleasant). CLOS is another example of the power of languages which allow programmers to add their own syntactic sugar.
Syntactic sugar can be very good. Message forwarding not only is a very useful piece of syntactic sugar, but also allows the creation of certain types of very convenient syntactic sugar to a language.
Re: Java Was Strongly Influenced by Objective-C
#47Earlier quoted context omitted.
As pointed out in my post, the alleged influence simply isn't there, or isn't there enough to justify the claim. Someone who cites Smalltalk as their inspiration before going off and creating a statically-typed OO language with primitive types and classes that aren't real objects either didn't understand Smalltalk or deliberately chose to distort the concepts imbued in it enough that they no longer have a right to cl…
They cited Obj-C, not Smalltalk. Specific people and specific aspects of the design are mentioned, you haven't actually described how it isn't influenced by Obj-C. Which, incidentally, has primitive types, the plain C part can do static type-checking, etc. In any event the claim is the design is influenced by Obj-C not that it is actually just like Obj-C, a distinction you seem to have trouble making.
Tell a C++ compiler engineer to make language "C++ minus templates and multiple inheritance plus GC" and you'll probably end up very close to Java.
What do you tell an objective-C compiler engineer to get Java? "Start with obc-c and ..."?
Maybe it's convergent independent evolution, but if obc-c is a branch to the left from C and C++ is a branch to the right, then claiming that Java comes from obj-c means Java must have pulled a very hard right early in its development.
Re: Java Was Strongly Influenced by Objective-C
#48Earlier quoted context omitted.
"They cited Obj-C, not Smalltalk." The author also cites Goslings "lots of experience" with Smalltalk. "In any event the claim is the design is influenced by Obj-C not that it is actually just like Obj-C, a distinction you seem to have trouble making." The influence is not sufficient to justify that claim any more than Java's garbage collection would justify its designers in describing Java as "Lispy" or "Lisp-like."
"We were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp." - Guy Steele, co-author of the Java spec
Re: Java Was Strongly Influenced by Objective-C
#49Perhaps learning Objective-C would make me a better Java coder. Alternately, maybe all the ObjC practices that would translate have already been written up as standard Java patterns or included in the standard Java books and all I'd get from it would be frustration because I can't apply anything neat I see.
One of my least favorite things Objective-C has is EXC_BAD_ACCESS (usually caused by memory mismanagement).
Re: Java Was Strongly Influenced by Objective-C
#50Perhaps learning Objective-C would make me a better Java coder. Alternately, maybe all the ObjC practices that would translate have already been written up as standard Java patterns or included in the standard Java books and all I'd get from it would be frustration because I can't apply anything neat I see.
I'm playing with some Objective-C at the moment. For me the most interesting thing is how blurred the line between ObjC/OOP/message passing and straight C is. It's the first language I've used where you can treat the high level part as not much more than a library with custom syntax. I'm sure the lispers live in this world all the time ;)