aspose file tools*
The moose likes Beginning Java and the fly likes about java oops Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about java oops" Watch "about java oops" New topic
Author

about java oops

Raj chiru
Ranch Hand

Joined: Aug 12, 2008
Posts: 141
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

Joined: Oct 02, 2003
Posts: 11314
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

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.


"If the facts don't fit the theory, get new facts" --Albert Einstein
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
"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

Joined: Aug 16, 2005
Posts: 14153
    
  18

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

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

Joined: Aug 16, 2005
Posts: 14153
    
  18

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Mar 13, 2009
Posts: 492

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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 01, 2009
Posts: 46
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.


regards,
Arka
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

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

Joined: Apr 16, 2008
Posts: 2187
Good point Fred
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about java oops