Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is java 100% object oriented

 
bapi kumar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, i want to know whether java is 100% object oriented? if yes how? if no why?
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"javaCloud in Earth" -

Please review our naming policy. JavaRanch requires that you use your real name when posting in the Saloon.

Please do not multiple the same question multiple times or in multiple forums. JavaRanch is a collection of interested volunteer Java users. There is no obligation for any one here to answer question, much less in a timely manner.
[ August 27, 2005: Message edited by: Michael Ernest ]
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say Java embodies 'practical OO', not pure OO. For example, if it was pure OO then primitives would be objects.
 
Patrick van Zandbeek
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, static methods wouldn't exist in pure OO. Don't believe, try asking a person that doesn't exist to wash your dishes for you and you'll see what I mean.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course the phrase "100% OO" doesn't have any defined meaning, anyway.

But I agree that there are definitely "more OO" languages than Java out there. For example, in Smalltalk even things like for loops and if statements are method calls.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The term "object oriented" and Smalltalk were invented at the same time to define each other, so that's probably about as good as it gets. I saw that Alan Kay (the inventor) was just laid off in the HP downsizing. I hope we don't see him on a corner with a "Will program for food" sign.

Smalltalk is all about sending messages. I wish we had kept that terminology in other OO languages.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
The term "object oriented" and Smalltalk were invented at the same time to define each other, so that's probably about as good as it gets. I saw that Alan Kay (the inventor) was just laid off in the HP downsizing. I hope we don't see him on a corner with a "Will program for food" sign.

Smalltalk is all about sending messages. I wish we had kept that terminology in other OO languages.


I agree!

Wasn't it Alan who said something along the lines of "When I invented the term OO, I hadn't something like C++ in mind..."
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OO programming is a style not a language.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mr. C Lamont Gilbert:
OO programming is a style not a language.


Well, I agree to the point that you can write OO programs in non-OO languages, and non-OO programs in OO languages. Still a language can support OO programming to different degrees, so asking what a language *does* support, and where it might lack some support, might be kind of reasonable, don't you agree?
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest definition for "pure" OO is whether only objects are permitted. In Java you have eight primitive types; end of story.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd also add that everything is a method call. As Ilja mentioned Smalltalk doesn't even have "if". In Java "if a == b" has no method calls. I only did Smalltalk for a couple months in 1995 so I'm sure I don' have it right, but it reads more like:

a == b true { code }

Call the == method on a with b as an argument, get back a boolean. Call the true method on the boolean with { code } as an argument and maybe it executes the code. The actual "syntax" of Smalltalk is far smaller than Java's; most of it is written in itself.

This is an entertaining discussion that we go around on every once in a while. I find everyone's answers interesting and educational, but the answer is of little real value. Java is an appropriate langauge for many tasks, it supports a lot of good OO ideas, but it's up to the designer to make something good out of it. You an make a better or worse OO design in a more or less OO language. The more OO langauges may help you out more, though, so if "100% OO design" is a goal, maybe choose Smalltalk, work in it for 20 years, and you'll get there.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
a == b true { code }


More like

a == b ifTrue: [code]



What makes this powerful is that you can, of course, use the same mechanism to invent your own constructs. It's very elegant, and something I miss in Java (even though my experience with Smalltalk is near to zero...)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic