In this section, we will discuss on the comparisons between C/C++ vs Java.
- History of Java Programming language.
- C++ vs Java
History of Java Programming language:
In previous section, we have understood the details of OOPs concept and the reason behind the evolution of OOPs concept. Now let’s discuss on the history of OOPs concept and Java Programming language.
In 1991, James Gosling started the development of Java. But it was not certified at that time and named as Oak. Later the name changed from Oak to Green.
In 1995, Sun Microsystem developed Java and released 1st JDK 1.0.
Syntax of java is mostly equal to C, C++. But one biggest advantage in java is “WORA”.
Confused what is “WORA”.
WORA is Write Once Run Anywhere. That means you can run the compiled java code in any platform without compiling again. But in C and C++ you need to compile again if you want to run the code in different platform.
In 1998, Java 1.2 released.
Popularity of Java motivated to develop the advance version of java like J2SE, J2EE, J2ME etc.
C/C++ vs Java:
There are lot of difference between C/C++ and Java. Let’s discuss the comparison one by one.
- First and foremost difference is C is procedural language and Java is Object-Oriented language.
- Structure like Union feature is not available in Java whereas in C/ C++ Union has taken the important part. Because of Union feature memory overlapping is happening. As this is not available in Java Programming language, memory overlapping issue is not available in Java.
- C/C++ both are platform dependent but Java is platform independent.
- In Java there is no concept like Pointer. But in C/ C++, most of the memory management is happened by pointer concept. Because of the point, security of the application may be broken. Addition to these it may crash the system if something went wrong. As Pointer is not available in java then it is more secure than C/C++.
- Java always checked he type when there is any assignment operation is taking place. Which is not available in C/C++.
- Multiple inheritance of a class can be possible in C++ but not in Java.
- Java takes more run time than C for automatic casting to object types and back.
- Java is more optimized language than C/C++.
- We can create our custom own package in java in form of class but not in C/C++.
- In Java, Memory management is taking place implicitly. There is no explicit memory management in java. If some memory is not used then it will be deleted by Garbage collection automatically.
- Java used both compiler and interpreter whereas only compiler is used by C/C++.
- Another biggest advantage of Java is wrapper class which is not available in C/C++. Due to wrapper class concept, Java provides the Object-oriented view of the data type like integer, float, byte, char etc.
- After compilation, java creates the .class file but C/C++ creates .exe file.
- In C/C++, header and preprocessor concept exist whereas in Java predefined package does the same functionality . We will lean more about the package in upcoming session.
- Java used import keyword to use the library function and packages instead of #include.
- In Java, you can develop Web application, but you cannot develop Web Application in C/C++.
- Java doesn’t support auto, external class etc. but C supports these classes.
- Global variable is another concept in which Java and C/C++ are different. Global variable concept is not available in Java whereas variable can be declared as Global in C/C++. Because of Global variable, data may be hacked. So in security point of view Java is more secure than C / C++.
- C/C++ supports Operator overloading but Java doesn’t support this.
From the above difference, we are clear now that Java is more popular than C/C++. If we want to check the comparison between C, C++ and java in graphical representation then below graph is the perfect example.