Is Java 100% Object Oriented

Is Java 100% object oriented?

When Java first appeared (versions 1.x) the JVM was really, really slow.
Not implementing primitives as first-class objects was a compromise they had taken for speed purposes, although I think in the long run it was a really bad decision.

"Object oriented" also means lots of things for lots of people.
You can have class-based OO (C++, Java, C#), or you can have prototype-based OO (Javascript, Lua).

100% object oriented doesn't mean much, really. Ruby also has problems that you'll encounter from time to time.

What bothers me about Java is that it doesn't provide the means to abstract ideas efficiently, to extend the language where it has problems. And whenever this issue was raised (see Guy Steele's "Growing a Language") the "oh noes, but what about Joe Sixpack?" argument is given. Even if you design a language that prevents shooting yourself in the foot, there's a difference between accidental complexity and real complexity (see No Silver Bullet) and mediocre developers will always find creative ways to shoot themselves.

For example Perl 5 is not object-oriented, but it is extensible enough that it allows Moose, an object system that allows very advanced techniques for dealing with the complexity of OO. And syntactic sugar is no problem.

Java is pure object oriented or not?

There are lot of arguments around whether Java is purely object oriented or not.
Java should be considered as purely object oriented language as it has wrapper classes.
So you can use Integer, Float etc. instead of int, float etc. (there are a total of eight primitive types).

But since Java has those eight primitive types, the critics will say Java is not purely object-oriented.

what makes java not pure object oriented language?

This is a homework question, right?

Primitive types, that's why. For instance try this:

int i = 42;
System.err.println(i.toString());

Every java program is Object Oriented

Because you cannot have a main that isn't part of a class. Hence a class must exist in order to have a valid program.

But that's really nit-picking since you don't actually have to instantiate that class to do something. You can write a complete program with just static methods that instantiate no objects at all.

Whether it's a useful program without using objects like System.out is another matter.

Some OO purists will argue that Java isn't pure OO and they're probably right (in my opinion). That doesn't make it any less useful.

What type of language Kotlin is? Pure OOP's or Functional

Actually most language analysts do not regard Java as a purely Object Oriented Language at all. All code needing to be in a class is not a good test, and a better test is everything in the language an object. In Java, many language elements, very notably methods and functions (functions were for a long time missing but then added recently through lambdas) were not available as objects.

Kotlin does correct many of the flaws of Java in being OO, although Java itself has also been slowly correcting these flaws. But generally it could be said that Kotlin could be considered more 'OO' than Java, largely as a benefit of being a newer design able to correct errors of the past.

Being able to write functions, as is now possible in Java with Lambdas, is not 'anti object oriented', the real test is if the functions themselves can be first class objects. By adding functions Java has not become less OO, and in fact Java is gradually becoming more OO over time. Research 'Is Java OO?'

Being able to support functional programming does not make a language 'non-oo' either. Consider (or research) scala.

Functional programming may be as old or even older than OO, but has become more popular recently and this is reflecting in more FP features being in new languages, and Kotlin also provides more support FP. No language is 'pure' FP and even a 'print' statement has side effects.

Kotlin provides support for both idioms, and may be more OO than Java but is considered less FP than more dedicated FP languages. More FP features may be added over time.

----- addition of a reference
For a source on Java with respect to OO, I suggest Dr Russel Winder as an authority, among other credentials, co-author of Developing Java Software which reached 3 editions. For one reference, see this video with a slide at 1:40 with the statement

Java is a 1990s imperative language that isn't really object-oriented.

As an acknowledged Java expert there is further explanation of this view both in that video and other presentations by Russel. This view is also expressed by many other Java experts and I may add references, but it would make this post too long to add as much detail for each example.

Is C++ completely object oriented language?

No, it isn't. You can write a valid, well-coded, excellently-styled C++ program without using an object even once.

C++ supports object-oriented programming, but OO is not intrinsic to the language. In fact, the main function isn't a member of an object.

In smalltalk or Java, you can't tie your shoes (or write "Hello, world") without at least one class.

(Of course, one can argue about Java being a completely object-oriented language too, because its primitives (say, int) are not objects.)

What is a pure object oriented language in the context of DCI?

A non-pure OO language in this context is a language were not everything is objects. Java for example have "primitive" types, which behave differently than objects. For example, Java's primitive types are passed by value, while Java passes references when it passes it's objects.

In contrast, Python treats everything as objects, and although it has built-in types, it has no primitive types, everything is objects.

I think you misunderstand the reference to classes. I don't think they say that a pure OO language does not have classes.

Difference between pure object oriented and object oriented language

Java is oop but not pure because, There are Primitive data type in java like int, float etc. and they are not classes/Objects. This is only one reason that java is not Pure OOP.
For example of Pure OOP . Objective C is Pure OOP language in which every thing is in the form of object.



Related Topics



Leave a reply



Submit