Wednesday, 27 May 2020

Platform Dependency

One of the most important features of java is platform independency and to understand how java achieved platform indecency, one must learn what is platform dependency. Let us understand what is a platform to understand platform dependency. Platform is a combination of hardware and software. Hardware mainly refers to microprocessors and software refers to the Operating system. For example, the platform in your computer could be the combination of i5 processor and windowsOS or it could be i9 processor and mac OS as shown below. However, from the software engineers perspective, platform only refers to OS.
Platform=Hardware + Software.
After getting to know what is platform let us now understand platform dependency by considering different cases of C language which is very much platform-independent.

we considered a file of C  programming language as the extension is  exmp.c.  Since  C  programming language is platform dependent programming language,  its platform of execution and platform of compilation must be the same.  In the above case the platform of compilation and platform of execution is the same which is windows operating system and hence we got the output.


we again considered the file of C programming language as the extension is exmp.c. In this case, we considered two computers having the same operating system connected via LAN connection. If we now take a copy of MLL(Machine Level Language) file from first computer and try to execute it on the second computer, according to you will the file execute????

 Compilation Phase  Execution Phase
 Windows windows
If in case you are still confused, just check two phases. COMPILATION PHASE    EXECUTION PHASE Windows   Windows If you can refer the above table, compilation happened on windows and execution happened on windows. Since platform of compilation is the same as that of platform of execution,the file gets executed which simply means you will get the output.
This case is the same as that of case ii except the platform of the second computer that is C
 Compilation Phase  Execution Phase
 Windows UNIX
If you can refer the above table, compilation happened on windows and execution happened on UNIX. Since the platform of compilation is not same as that of platform of execution file will not get executed which simply means you will not get the output.

The  problem  faced  in  C  or  C++  programming language  is that their compiler directly converts High-level language code to machine level language codeand if this code is copied on other type of operating system and tried to execute, it doesn’t   work   because   the   code was   written   using   platform   dependent programming language.To reslove this issue, JAMES GOSLING, the inventor of java programming language which was platform-independent.

Let us now learn how java achieved platform independence

Let us assume you are writing code using java on your computer which has windows os. Since Machine understands machine-level code not your high-level code, the conversion must happens. Let us see how exactly conversion happens in java. Initially, your HLL code is given as input to the compiler but the java compiler will not give MLL code as output like c and c++ compiler rather it takes HLL as input and gives a special type of code as output called as byte code which is platform-independent. Byte code is neither HLL code nor MLL code, hence it is also referred to as intermediate code. If you can recollect machine understands only MLL code but java compiler gave you byte code. To resolve this,  James  Gosling provided software called JVM(Java virtual Machine)which was platform-dependent that is different OS have different JVM. Since you are writing code on windows OS, you will have to download windows compatible  JVM  .  JVM  will now convert  byte code to machine level code which machine can easily understand. In this way, java achieved platform independence using a special type  of code which is byte code.



0 Comments:

Post a Comment

Popular Posts

Categories

AI (33) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (146) C (77) C# (12) C++ (82) Course (67) Coursera (198) Cybersecurity (24) data management (11) Data Science (106) Data Strucures (8) Deep Learning (13) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (21) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (46) Meta (18) MICHIGAN (5) microsoft (4) Nvidia (1) Pandas (3) PHP (20) Projects (29) Python (893) Python Coding Challenge (285) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (42) UX Research (1) web application (8)

Followers

Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses