top | item 1118599

Java Was Strongly Influenced by Objective-C

94 points| almakdad | 16 years ago |cs.gmu.edu

50 comments

order

hrabago|16 years ago

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|16 years ago

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|16 years ago

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|16 years ago

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

oopd|16 years ago

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|16 years ago

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?

michaelneale|16 years ago

>very clearly should be objects, such as classes, are not objects

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?

prodigal_erik|16 years ago

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

inferno0069|16 years ago

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|16 years ago

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

martingordon|16 years ago

One of my favorite things Objective-C has over Java is no NullPointerExceptions (it's legal to send a message to nil).

One of my least favorite things Objective-C has is EXC_BAD_ACCESS (usually caused by memory mismanagement).

warwick|16 years ago

Learning another programming language will almost always make you a better coder. It gives you perspective on the language you spend most of your time in, and lets you see patterns that are non-obvious is your 'main' language.

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.

pkaler|16 years ago

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|16 years ago

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|16 years ago

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.

ido|16 years ago

I think 'remind' might be the word you are looking for.

blasdel|16 years ago

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

bad_user|16 years ago

What do you mean?

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

pvg|16 years ago

There are. Think about classloaders and the whole dynamic code loading thing. Every single object has a class object associated with it.

lucifer|16 years ago

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

duncanj|16 years ago

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