Java Was Strongly Influenced by Objective-C
cs.gmu.edu
cs.gmu.edu
(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."
Compare to Java where it's not even possible to forward messages determined at runtime, you have to generate stubs before compiling. AFAIK.
Personally if I were to choose, I'd trade some syntactic sugar for a decent garbage-collector. But that's just me :)
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.
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.
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?
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?
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.
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."
Well classes are objects themselves, but not necessarily related in a useful way to the objects which they instantiate. You can't do as much with them (other then look at them, or load new ones) - or do you mean more a prototype based OO?
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?
One of my least favorite things Objective-C has is EXC_BAD_ACCESS (usually caused by memory mismanagement).
To really benefit from learning another programming language, make sure that you actually learn the language, not just hack around in it for the weekend and say you know it.
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.
Classes are in some sense like objects, meaning they can hold their own state, but there is no notion of meta-classes like in Smalltalk.
The class in the JVM is like a module that holds functions and attributes. And the JVM byte-code is very class-centric.
The objects themselves are probably not what you think they are. The JVM currently has no notion of "call method next() on object O" ... that's done with something like ... invoke_virtual Enumerable.next(obj). The bytecode "invoke_virtual" is responsible for doing the single-dispatching (subtype-polymorphism) at runtime, otherwise it looks just like an invoke_static ... so the compiler is crucial for generating the correct byte-code, because the class has to be known at runtime ;)
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; Class c = SomeRandomClass.class;
Object x=c.newInstance();In Java's type system, classes are 'first class objects':
// 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.
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.
if(foo instanceof SomeClassObject) ...
or if(SomeClassObject.isInstance(foo)) ...