Don't Classes in Java get boiled off in the compiler? There are no "class objects" at runtime that I've ever seen.
There are. Think about classloaders and the whole dynamic code loading thing. Every single object has a class object associated with it.
Java Was Strongly Influenced by Objective-C
31–40 of 53 posts
Re: Java Was Strongly Influenced by Objective-C
#32Earlier quoted context omitted.
Too be fair, message forwarding is a pain in the ass in ObjC as well.
It's not really that hard, is it? You just have to implement methodSignatureForSelector and forwardInvocation. Compare to Java where it's not even possible to forward messages determined at runtime, you have to generate stubs before compiling. AFAIK.
Re: Java Was Strongly Influenced by Objective-C
#33Earlier quoted context omitted.
It's not really that hard, is it? You just have to implement methodSignatureForSelector and forwardInvocation. Compare to Java where it's not even possible to forward messages determined at runtime, you have to generate stubs before compiling. AFAIK.
You have to have a method to forward to that accepts the right number of arguments of the right type. It's a far cry from overriding methodNotFound. I tried to recreate the ActiveRecord find style in SimpleData ( http://github.com/briancollins/SimpleData ) and it is just so hackish.
Re: Java Was Strongly Influenced by Objective-C
#34Earlier quoted context omitted.
> some things that very clearly should be objects, such as classes, are not objects I don't get it. java.lang.Object.getClass() always returns an instance of java.lang.Class. What other behavior would you require before saying that Java classes are objects?
In Smalltalk, when you type the name of a class you are really referencing a global variable that refers to a class object. "Dictionary new" means send the message #new to Dictionary, and the Dictionary class object will respond by giving you a new instance of itself. "Dictionary compile: 'foo ^ 42' classified: #accessing" will add a method "foo" to Dictionary under the "accessing" category that will return 42 (an in…
Re: Java Was Strongly Influenced by Objective-C
#35Don't Classes in Java get boiled off in the compiler? There are no "class objects" at runtime that I've ever seen.
// unseen? if (foo.getClass() instanceof someClassObject) ...
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.
Re: Java Was Strongly Influenced by Objective-C
#36Earlier quoted context omitted.
You have to have a method to forward to that accepts the right number of arguments of the right type. It's a far cry from overriding methodNotFound. I tried to recreate the ActiveRecord find style in SimpleData ( http://github.com/briancollins/SimpleData ) and it is just so hackish.
Or just a method which takes a NSInvocation object...
Re: Java Was Strongly Influenced by Objective-C
#37Earlier quoted context omitted.
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.
"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."
Re: Java Was Strongly Influenced by Objective-C
#38Earlier 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?
Re: Java Was Strongly Influenced by Objective-C
#39Earlier quoted context omitted.
It's not really that hard, is it? You just have to implement methodSignatureForSelector and forwardInvocation. Compare to Java where it's not even possible to forward messages determined at runtime, you have to generate stubs before compiling. AFAIK.
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 :)
Re: Java Was Strongly Influenced by Objective-C
#40Earlier quoted context omitted.
But can you pass classes around as objects after they're loaded? Do they have a value beyond their identifier?
Yes, although Java's reflection is somewhat of a pain in the ass and limited in many ways. But you can take a Class object and call newInstance(), and it will invoke the class's no-arg constructor.
Class c = [SomeRandomClass class];
id thingy = [[c alloc] init];
but Java won't let you do the equivalent: Class c = SomeRandomClass;
Object x = new c;