

Java Was Strongly Influenced by Objective-C - almakdad
http://cs.gmu.edu/~sean/stuff/java-objc.html

======
hrabago
Goes to show that just because you model something after another, it doesn't
mean they'll look or feel similar. The underlying design of Java might have
been influenced by Objective C, but the use of the two languages feel very
different.

------
qw
Interview from <http://www.gotw.ca/publications/c_family_interview.htm>

(I'm including Stoustrup, since C++ was probably one of the influences of the
choice of syntax familiy)

Q: What languages, or features of languages, inspired you?

 _Stroustrup_ : In addition to Simula67, my favorite language at the time was
Algol68. I think that "Algol68 with Classes" would have been a better language
than "C with Classes." However, it would have been stillborn.

 _Gosling_ : They're all over the map. Using Lisp, the thing that influenced
me the most was the incredible difference garbage collection made. Using
Simula and being a local maintainer of the Simula compiler was really what
introduced me to objects and got me thinking about objects. Using languages
like Pascal got me really thinking about modeling. Languages like Modula-3
really pushed things like exception mechanisms. I've used a lot of languages,
and a lot of them have been influential. You can go through everything in Java
and say, "this came from there, and this came from there."

------
tedunangst
Except it seems to be missing all the features that make Objective-C
"Objective-C" in my mind. How do you implement method missing/message
forwarding in Java? Oh, that's right, your code doesn't even compile.

~~~
naz
Too be fair, message forwarding is a pain in the ass in ObjC as well.

~~~
tlrobinson
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.

~~~
bad_user
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 :)

~~~
ryanpetrich
Message forwarding is not syntactic sugar!

~~~
ekiru
It is. In Objective C: [obj doFoo] would be analogous to this in a Java-like
language: MethodSpec s = new MethodSpec("doFoo"); (obj.hasMethod(ms) ?
obj.performMethod(ms) : obj.handleMissingMethod(ms)

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.

------
oopd
The use of the word "influenced" to describe the effect had on Java's design
process by Smalltalk, Objective-C and other languages of good repute is really
somewhat misleading.

Certainly, there is _some_ identifiable influence. For example, the concept of
a JIT-ing virtual machine comes straight from Smalltalk (Deutsch & Schiffman,
1984), and it would also not surprise me if the APIs of Smalltalk and NeXTSTEP
influenced the design of Java's somewhat. But that is largely where the
influence ends: on the implementation of the language rather than on the
language itself.

Java _the language_ belongs on the same branch of the OO family tree with C++,
C# and other strong statically-typed OO languages--not on the branch with
Smalltalk and company. Yes, Java's object model is class-based, single-
inheritance and single-dispatch, but its model has little else in common with
Smalltalk's. If it was designed with Smalltalk in mind, then it constitutes a
dangerous misunderstanding of it. I do not mean the fact that "everything" in
Java is not an object, but rather that some things that very clearly should be
objects, such as classes, are not objects is alone enough to disqualify it as
one of Smalltalk's legitimate offspring.

The people who assert over and over again that Java was influenced by this
language or that language do so because this language or that language has a
better reputation among programmers than Java, and it is hoped that by doing
so perhaps some of that reputation might rub-off on the hapless language.

~~~
pvg
_The people who assert over and over again that Java was influenced by this
language or that language do so because this language or that language has a
better reputation among programmers than Java_

The post was written by one of the people who worked on Java, not somebody
trying to impress you by associating Java with some language you like better.
Are you trying to say Patrick Naughton is just making this up?

~~~
oopd
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 claim it as an antecedent.

Gosling and others have been making claims of this sort for years, and yes, I
_do_ believe that they do so with the hope of improving their language's
reputation, and further, to give their users the impression that they aren't
missing out on anything by sticking with Java; that Gosing et al. studied the
cream of the language crop when designing Java, took the good parts and left
the cruft behind, so why bother trying anything else?

~~~
pvg
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.

~~~
oopd
"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."

~~~
10ren
"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

~~~
tedunangst
Guy Steele apparently measures distance on a log scale. :)

------
inferno0069
Perhaps 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.

~~~
DougBTX
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 ;)

~~~
zaphar
Yes we do.

------
pkaler
Most languages are influenced by languages they proceed.

Simula, C++, C#, and Java are clearly method calling languages. Smalltalk and
Objective-C are clearly message passing languages. That is the biggest
distinction.

You will always be able to find a particular feature in a particular language
that is influenced by languages that have preceded it.

------
alexk7
I just want to remember everyone that Objective-C is nothing more than
Smalltalk with C backward compatibility. Also, the static type checking in
early Java is pretty much the same thing as in early C++ (when both were
without templates/generics).

~~~
protomyth
I think I would argue with the "nothing more" part. It has split and evolves
from its origins. Also, the combination has some decent advantages over
straight Smalltalk.

------
blasdel
Don't Classes in Java get boiled off in the compiler? There are no "class
objects" at runtime that I've ever seen.

~~~
lucifer

        // unseen?
        if (foo.getClass() instanceof someClassObject) ...

~~~
blasdel
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.

~~~
lucifer
> In this case isn't someClassObject just a literal that's resolved at
> compile-time and erased into a simple identifier symbol?

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...](http://java.sun.com/docs/books/jls/second_edition/html/execution.doc.html#44487)

> 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.

------
duncanj
I always felt that Java's design resembled Modula-3.

