Saturday, January 18, 2020

How do Java and C# create cross-platform portable programs, and why can’t C++ ?

How do Java and C# create cross-platform portable programs, and 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


  1. Portability of any language depends on the object code created by compiler.
  2. C++ Compiler produces machine code which is directly executed by the CPU.
  3. C++ Code is thus machine dependent and tied to particular Operating System (OS).
  4. 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


  1. Java is created by Sun Micro System. [See : What is Java ?]
  2. Java Compiler produces Intermediate code called Byte Code.
  3. Byte Code i.e intermediate code is executed by the Run Time Environment.
  4. In Java Run Time Environment is called as “JVM” [ Java Virtual Machine]
  5. If we have JVM already installed on any platform then JVM can produce machine dependent Code based on the intermediate code.
  6. Here is descriptive reason – Why Java is portable ?




Consider Scenario of C# Programming Language

  1. C# was created by Microsoft.
  2. C# compiler produces intermediate code called as MSIL. (MicroSoft Intermediate Language).
  3. MSIL i.e intermediate code is executed by CLR (Common Language Run Time)
  4. 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

IMG Scroll Animation (yes/no)

recent/hot-colored