Both Java and C++ are efficient programming languages that use object-oriented programming(OOPs) paradigm. Java follows OOPs more than C++. Both support OOPs features like:
In this article, we are going to discuss the platform independence of Java and why C++ is not supporting platform independency.
Before knowing why java is platform independent let’s have some brief about compiler phases:
We have heard that java is developed to eliminate the various drawbacks of C, C++. Although Java has mostly inherited its syntax from C++ and some major features as well. Java is preferred in almost all major organizations because it supports “code once, runs anywhere” made it platform-independent and easy to use and upgrade.
Before knowing why java is platform independent let’s have some brief about compiler phases:
Interpret symbols, their types, and their relations with each other.
In the analysis-synthesis model of a compiler, the front end of a compiler translates a source program into an independent intermediate code.
It transforms the code and tries to improve the code by making it consume fewer resources (i.e. CPU, Memory) and deliver high speed.
Use the optimized intermediate code and generates target code or machine code on which machine can operate easily.
Java:
C++: