• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about java oops

 
Raj chiru
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q: Why java is not pure object oriented programming? If it is pure object oriented, java will never work, why?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been repeatedly asked and discussed here, and there is no answer. People don't agree on what "pure OO" means. So, unless you define what you think it means, nobody can give you a meaningful answer.
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't a pure OOP language one in which everything is an object, even literals?

I've recently started learning Ruby, and that is a pure OOP language.

Hunter.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"object-oriented" is a design concept. There can be many, many different ways to program in an "object-oriented" way.

A "pure" object-oriented language would be one that supported "object-oriented" design concepts.

Whether something is pure or not would depend upon how the programmer writes a program. One can certainly create pure OO programs with Java. And one can certainly create programs that are not object-oriented with Java.

Java is a pure OO language. If you think it is not, then please describe some "object-oriented" thing that you cannot implement using Java.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With "pure OO", people often mean that everything is an object. That's not the case in Java, because in Java there are for example primitive types, which are not objects - so because of that reason, they say Java is not a pure OO language.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hunter McMillen wrote:I've recently started learning Ruby, and that is a pure OOP language.


correct me if i'm wrong, since i don't know a thing about Ruby, but does it have operators? you know, "+", "=", etc?

if so, those are NOT objects. Some folks would say that those should be implemented as methods:

2.plus(3)

for it to be PURE OO.

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Ruby has operators, but they are more or less just methods with funny names and can be redefined or overloaded if you like. You can use the normal method call syntax with operators in Ruby (altough it looks a bit silly):


I don't really agree that having operators means that it is "less OO". You could also say that methods are not objects and therefore it's not "pure OO".
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Ruby things like the "if" operater aren't objects--does that make it less pure? How about in Smalltalk?

Re: Java's OOPness--I've *always* considered it OOPLite, because I came to it from a Smalltalk background. Arrays are particularly irksome; I don't feel I should have to use a static utility class to directly manipulate an array. If arrays were "real" objects I wouldn't have to.

(And personally I *would* say if methods aren't objects (although we can *get* a method's object) that it's "less pure.")
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Primitive types which belong to objects does not make Java not "pure OO". To be hard-headed, everything is converted to machine language anyway so the concept of everything being an "object" is weak. Nothing is an "object" when it is executing, its all binary data.010101010101010101010101010no objects here
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right but at the programmer level it's all objects and types correct?
the machine does most of the work with all the binary data

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like he said, he's being hard-headed (and potentially forgetting about Rekursiv, but in general, he's right).

It's not a particularly useful distinction for this discussion, though, and I don't find anything particularly weak about "everything being an object" when discussing OOPLs.
 
Arka Guhathakurta
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I do not know if a language is purely object oriented or impurely object oriented. To me a language is either Object Oriented or it is NOT. Correct me if I am wrong.... what we learnt from our BASICS it suggests:-
A language is object oriented if:
1. It has Polymorphism.
2. Encapsulation.
3. Inheritance.

Also note that two aspects come as by-products in OOPs:
1. Coupling: Two classes are said to be tightly coupled if they know each other's functionality and purpose.
2. Cohesion: The class focuses exactly on the reason for which it is made.

I guess JAVA is indeed an Object Oriented Programming Language...if the above definition is correct.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12084
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my point about Ruby and operators was less about Ruby being 'pure OO' that it was supposed to illustrate that DIFFERENT PEOPLE CONSIDER "PURE OO" TO MEAN DIFFERENT THINGS.

Nobody's definition is more or less valid (well, ok, SOME are less valid). I don't care if you consider Ruby, Java, Smalltalk or even C pure OO or not, because we're all going to consider the phrase to mean something different.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point Fred
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic