You are Visitor Number

Wednesday, January 27, 2010

Is Java a Pure Object Oriented Language? :-O

Though I’m not a big fan of the Object Oriented Programming paradigm, I believe that it has influenced millions of software engineers across the world. The proliferation of enterprises that recognized the potential of OOAD in maintaining their ever-evolving colossal systems was one of the fundamental reasons for a sudden upsurge in java/.net developer vacancies in our industry. You know how it works in the world of classes and interfaces - releasing 100 patches per year is not a big deal ;-)

This of course have dampened the rate of innovation in the field of computers but not without significant improvements in OOAD frameworks, tools, utilities, platforms and so on and so forth. I would account it as a result of some sort of local internal bran drain where talent gets sucked in to the lucrative world of enterprise applications and dot coms. This compels us to digress into a discussion on various other subfields like programming principles, theory of computation, compilers, data structures, algorithms and more. But, let’s start with a big shot in the OO world - Java.


The success of Java can be truly explained using genetic algorithmic terms as a result of cross over. In the world of genetic programming, based on the fitness function of two individuals, they are crossed over to create a new individual with a better fitness than both the parents. This new individual will belong to the new generation. Sorry about trying to bring in the concept of genetic programming way too early but my intention was to look descent enough not to use terms from biology and still explain how we can look at smalltalk and C++ as technologies who contributed to the success of Java.


The object orientation principles and the concept of virtual machine from Smalltalk and the popularity of syntax from C++ laid down the foundation for Java. Also, as java was initially targeted for the consumer electronics industry to achieve the capability to be run on a host of diverse processors, it had to do away with the complexities of C++. The pointers, multiple inheritance, scope resolution etc were few of the overheads that java got rid of. So one thing is for sure, java was well thought about while it was being designed. But if you ask me whether java is a pure OO language, my answer would be no.


There are ongoing discussions and debates over various topics including the use of static fields and methods, lack of direct multiple inheritance etc that are used as arguments to disprove that java is 100% OO. However, one of the fundamental rules of being a language that Is purely OO is to be within the OO framework and constrain itself to follow the paradigm. Like Smalltalk for example.


When you say Integer i = new Integer(10); we are all good, but when you say int i = 10; the framework gets polluted with a non-object entity. In the world of a pure object oriented programming language everything must be looked at as objects with characters and behaviors. Like a Dog with a tail that can bark or like java.lang.Integer object of value 10 with the ability to retrieve the attribute using a message like intValue(). But, when you talk about the type ‘int’, you do not associate it with attributes and methods. Consequently, it spills outside the OO philosophy and this happens to be the case with every primitive type available in java including byte, char, int, long etc….


Having said that, to a technology psycho this could be important, but the fact is that Java is an ideal language for Object Oriented development and sometimes though not directly, it is good to have the power of both worlds, OO and procedure oriented, to enjoy what I call natural programming. We'll deal with it shortly ;-)

No comments:

Post a Comment