WHY Java


Why java was invented


         Like C++, Java is also Object Oriented programming language.  But there are lot many differences in both languages. To explain why create java; I would focus on only several of them.


·        Platform Independence

Famous motto of Java is “Write Once Run Anywhere”. Let’s see what it is.

C++ code compiles directly to machine instructions. Different platforms have different compilers and their way of implementing language is also different. So code written for a particular platform may not work for other.


Contrary to this, Java has its own execution environment known as Java Runtime Environment (JRE). It is a software environment which runs on top of existing hardware environment. Thus it is platform independent. It consists of Java Virtual Machine which compiles code and converts into bytecode, not a machine code which is hardware dependent. This bytecode is hardware independent and can be executed on any platform which has JRE installed.



·        Pointer

C++ and Java both supports pointers. In C++ pointers can be accessed directly whereas in Java pointers are present in background only, you cannot write program for pointer.



·        Multithreading

C++ don’t have inbuilt support for thread. It relies on third party library.

Java has inbuilt support for thread.



·        Documentation comment

C++ doesn’t support documentation comment. Developer has to write code’s documentation manually.

Java supports documentation comment to automatically generate documentation from source code.



·        Garbage collector

In C/C++ programmer needs to write code to destroy unnecessary objects. If not written, sometimes sufficient memory may not be available to create new object. This causes OutOfMemoryException. So concept of Garbage Collector came into picture. GC frees memory occupied by objects that are no longer in use by program.

Unfortunately, C++ doesn’t have garbage collector. Java has inbuilt garbage collector which runs automatically in background and also can be called in code.



1 comment:

Operators in Java

Operator is a symbol which is used to perform operation on data. Eg. +,-,/,* etc. Do you know : Operator and operan...

Popular