Objective-C vs. gcj (was: Re: Newbie questions)
Kresten Krab Thorup
krab@daimi.au.dk
Sat Apr 1 00:00:00 GMT 2000
Jeff Sturm <jsturm@sigma6.com> writes:
> > When you say "weak" typing, what do you mean?
>> He means Objective-C doesn't do any compile-time binding or even
> checking of method invocations. Every instance variable can be declared
> as "id" which is equivalent to Java's java.lang.Object class.
Equivalent is not quite right. The type `id' is a super-type for all
other types (including root classes such as Object); and indirections
(i.e., method calls) via a reference of type `id' are runtime
type-checked. The compiler will issue warnings in some cases, i.e.,
if it has not "seen" a method declaration with the given name.
> method name is misspelled or can't be resolved at runtime for any
> reason, a runtime error is thrown and the program generally aborts
> (which I consider a drawback of the language).
Right.
> Note that the Java _language_ is strongly typed though bytecode is
> not... all names are dynamically resolved from bytecode, just as in
> Obj-C.
Java byte-code is stronly type checked. The Verifier implements
almost the exact same semantics checks as the compiler does.
> > What is categorization?
The term `categories' stems from Smalltalk terminology. In the file
format for `filing in' code in a ST system, there is syntax that
allows methods to be added to existing classes. This is exactly the
functionality of categories. In Objective C, such categories can be
loaded at runtime.
> Objective-C has a neat feature which makes it extremely simple to write
> delegate classes. The runtime attempts to dispatch a method invocation
> to the named method, but if a method is not found it defaults to the
> "forward:" (?) method, which can be overridden to route the invocation
> to another object, or even marshal the arguments for delivery to a
> remote object. Obj-C had a very elegant solution to distributed
> programming that way.
>> Similar tricks could be performed with Java reflection, I'd guess.
In Java, this is not possible; it would require a change to the
language semantics. The new 1.3 proxy stuff does something that comes
close, though.
-- Kresten
Kresten Krab Thorup "I like my eggs ploded"
Department of Computer Science, University of Aarhus
Aabogade 34, DK-8200 Aarhus N, Denmark
+45 8942 5665 (office), +45 2343 4626 (mobile)
More information about the Java
mailing list