Thursday, 12 July 2012

How Java is portable ? What makes Java and C# portable ?


why can’t C++ ?

Why C++ is not cross platform dependent ? Why C++ is not a portable ? How Java is portable ? What makes Java and C# portable ? We have summarized all the reasons that makes Java and C# portable and C++ :


Reason :

Consider Scenario of C++ Language

Portability of any language depends on the object code created by compiler.
C++ Compiler produces machine code which is directly executed by the CPU.
C++ Code is thus machine dependent and tied to particular Operating System (OS).
If we try to execute C++ program on the another Operating C++ then we must recompile program before executing program.
Consider Scenario of Java Programming Language




Java is created by Sun Micro System.
Java Compiler produces Intermediate code called Byte Code.
Byte Code i.e intermediate code is executed by the Run Time Environment.
In Java Run Time Environment is called as “JVM” [ Java Virtual Machine]
If we have JVM already installed on any platform then JVM can produce machine dependent Code based on the intermediate code.
Consider Scenario of C# Programming Language


C# was created by Microsoft.
C# compiler produces intermediate code called as MSIL. (MicroSoft Intermediate Language).
MSIL i.e intermediate code is executed by CLR (Common Language Run Time)
If we have CLR already implemented on any platform then CLR can produce machine dependent Code based on the intermediate code.

No comments:

Post a Comment

There was an error in this gadget