Java's Platform Independence Explained

One of today’s most interesting learning was understanding the platform-independent nature of Java. Why language like java/python are platform independent and C/C++ are platform dependent? A common misconception is that high-level languages themselves are platform independent. In reality, platform independence comes from how the code is processed internally. First let's see what happens when a C/C++ code is run? The high level language code is translated using compiler into a machine level Object code (.obj file). [Key note: Machine level code are machine dependent because underlying operating system has it's own way of processing(specific to OS + CPU architecture)]. Object code is further linked with library files (.lib) using linker and than executable file (.exe) is generated and executed. Now, let's come to Java. Java follows a different path, the source code is compiled to Byte code(.class) using java compiler. Byte Code is neither in HLL nor in MLL i.e secure and platform independent. Now byte code is given to JVM. Since every operating system has its own JVM, the same bytecode can run anywhere. JVM takes the byte code and translates it into MLL using interpreter and executed statement by statement. That's the magic behind Write Once, Run Anywhere (WORA) This design choice is what makes Java incredibly portable and one of the reasons it remains so widely used. Greatful for the insightful session and guidence by Syed Zabi Ulla sir. Always fascinating to see how much happens behind the scenes when we run even a simple program. #Java #Programming #ComputerScience #Coding #JVM #PlatformIndependence #ObjectOrientedProgramming

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories