2

I know that Java is mostly object oriented language since you can do things like encapsulation, inheritance, and run-time polymorphism.

But when I watch a lot of talks on youtube about RxJava they say under Android you work with imperative rules? Does this relate to the life-cycle methods?

When I work with POJO's isn't that Object Oriented? Does this have to with how we handle data through our architecture layers? I'm getting confused with all these 'paradigms' and 'styles' especially since RxAndroid is getting thrown into the mix with 'functional-reactive' style.

GhostCat
  • 137,827
  • 25
  • 176
  • 248

4 Answers4

3

First of all: Android is an operating system, not a programming language. That language is mainly object oriented, but lately a lot of effort is going into making java more suitable for functional programming. Frameworks such as RxJava emphasize that, too.

Of course, there are different programming models that can be used on the Android platform.

Coming from there: there is simply no sense in assuming that this large, complex environment can be reduced to some simple, always correct single word description. It is a combination of many different aspects.

Or as the US citizens say: in pluribus unum.

GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • I didn't mean to imply that Android is programming language, I think I should update it to "Does the Android Framework promote Imperative or Object Oriented Design" also thanks for answering! – gabriel carrillo May 30 '17 at 03:09
2

Android itself is a platform, not a language, so the question contains a category mistake.

In general, the only way this kind of question can be definitively answered is by resort to fundamental definitions. These were stated by Peter Wegner in 1987 in the paper 'Dimensions of Object-based Language Design'.

Wegner provides the following definitions:

  • Object-based: a language is object-based if it supports objects as a language feature.
  • Class-based: an object-based language is class-based (classical) if every object has a class.
  • Object-oriented: an object-based language is object-oriented if its objects belong to classes and class hierarchies can be incrementally designed by an inheritance mechanism.
user207421
  • 305,947
  • 44
  • 307
  • 483
0

Some people say that Java is more like a hybrid, taking this piece from this article:

That said, Java is not a pure Object-Oriented language. Someone said Java is a hybrid, which, IMO, is an accurate description. I would posit Java is a dirty hybrid of an OO language. Consider: String s = string2.trim(); First, since "String" is immutable, the above code reeks of functional programming. The "trim()" operation should cause the whitespace to be trimmed off both ends of "string2", without needing reassignment. That is to say, operations should act on the data as close to the object as possible. This, to me, makes Java feel dirty (it also leads to tightly-coupled systems due to the prevalence of "get" accessor methods, but that's another topic entirely). Ahem, what? That example is perfectly OO. Object-orientation does not make mutable state necessary. Actually, since strings are passed around so often, the lack of mutator methods really just saves a lot of headache. Second, Java cannot alter the behaviour of all messages. It mixes the types of "operations" available to objects, depending on their type. The "+" is equally applicable to ints as it is Strings, but not to Matrices, or Colors. This isn't so bad, because you can do matrix.add( matrix ), but serves to illustrate the point about Java being 'dirty' (or 'impure', if you prefer). Lastly, it is a hybrid to provide performance gains. Even though Smalltalk has an advanced virtual machine, its inability (when I was using it) to provide a machine-correlated bytecode for integer math placed a significant performance impact on its entire environment. Being a hybrid, Java cannot be called a true Object-Oriented language. But then, why does it matter?Use the right tool for the job and life will be happy!*

So:

You can work all like procedural programming if you want, and not use anything of OOP, but also, is not pure OOP programming, because not everything in Java is an object.

Also:

Java8 introduces some concepts about Functional programming, one of them is the use of lambdas. In resume, Java is imperative, OOP and functional language(dep on version).

PEHLAJ
  • 9,980
  • 9
  • 41
  • 53
developer_hatch
  • 15,898
  • 3
  • 42
  • 75
0

I think you've got it a little bit wrong.

Java is an imperative language. You'd be better to ask what the difference between declarative vs imperative programming, or the difference between object oriented and functional programming.

Here is a great article on imperative vs declarative: https://tylermcginnis.com/imperative-vs-declarative-programming/

Here is a stack overflow answer explaining the difference between object oriented and functional: Functional programming vs Object Oriented programming

Android provides a framework written in java. Android isn't a language, but Java is. Java is an object oriented language.

I hope that clears things up a bit.

Dillon Burton
  • 131
  • 10