Thursday, July 23, 2015

Platform Dependent Codes



Before understanding platform in-dependency let us see first the problems related to platform dependent languages and codes. C and C++ languages were widely used before Java came into picture. Let us view a diagram first to analyze working of programming languages.


In above picture, we have created a program using C or C++ language i.e. source code. Now as we all know we have to convert this program for machine understandable form or we can say some sort of binary code.
      Compiler is a program that converts one code to another code. If our program does not contain any errors then it will be successfully complied and we will get an equivalent binary code.

Now we have Windows Operating System and Intel Processor, which is obviously 80% of Indians do have ;D This is our Platform.

A processor is responsible for executing actual instructions of every program. It has its instruction set defined in it. For example we are taking for addition instruction (+) a binary code 110011. That simply means if 110011 code comes from a program then processor will perform addition.

So from that you can conclude that the responsibility of compiler is to convert + instruction from source code to 110011 in binary code. Likewise it will compile the whole source code to binary code.

You run the code and it is running very fine. You are happy that you completed your project and you are ready to distribute sweets.

Now consider a situation that this application you have developed was for a client that is not from India but abroad. Now we have to give him/her the application and we sent the binary executable file. Obviously we don't want to send our source code but will send the binary executable.
It is not necessary that your client also have the same configuration of machine that you have. Suppose he/she have Apple machine and Mac O.S.,  which is different from our platform. So it will also have different machine instructions for its processor. Consider:

+ = 101010    (for Mac)

Now that our binary file created, compatible for windows will not be understood by Mac O.S. And your situation will be like this:



The problem lies due to different platforms of O.S. and machines. The code that is compiled at Windows is loyal to Windows. That's the reason it is also known as Native Code.

Now what you can do here is purchase machine of Apple and Mac O.S., compile the same source code at this machine, it will generate Native code for Mac. Give that binary to your client and make your client happy.

This problem of platform dependency was huge at previous times. You have always seen for many softwares when you download them. The website gives you different binaries for different O.S.

To understand the Platform In-dependency click next.

Next

No comments:

Post a Comment