Machine Independence programs are those that deliver the same output on all computer systems, independent of the computer system on which they are being executed. A program is machine-independent if it can be executed successfully without any errors on more than one type of hardware platform.
Platform-Independent programs are developed so that these programs can be executed on different machines without any errors and executable codes can be distributed easily. When many programs are combined together it builds software. The software is developed not for one computer system but for all those persons that need it. So the software must be developed using a methodology that makes it executable on all computer hardware and Operating Systems.
The platform-independent programs should be executable on different operating systems such as Microsoft Windows, Linux, and machOS. A program can be made platform-independent if the language in which the program is being developed has the grammar to develop platform-independent programs. Frameworks such as React Native, Xamarin, Codename One, Flutter, etc. are used to develop platform-independent programs.
Execution of the program is influenced by the type of hardware on which the program is being executed and the operating system that is managing that hardware. There exist different types of hardware that can support parallel computing or sequential computing. Hardware requirements for parallel computing and hardware requirements for sequential computing are different. Since the hardware is different, the instruction format is also different. As the instruction format is different, the language should generate different instructions for different hardware, this makes programs platform dependent. To make the program platform independent the language must generate instructions that make it executable for all types of hardware, this makes the program platform-independent.
Nowadays programs are also being executed on different mobile devices such as smartphones and tablets.
Developing different programs for each type of hardware is a time-consuming and costly process. So the programs must be developed in such a way that it becomes executable on different hardware devices without any errors.
Techniques of developing Platform Independent Programs
If the software is being developed for selling purposes the software must be developed using methodology that makes it platform-independent. Two techniques are used to develop platform-independent programs. First, compiling the developed program into machine language as per the operating system and hardware, Second, converting the source code into intermediate language and compile that intermediate language.
The source code of a program can be different for the different operating systems and maintaining different source codes for the same program is a cumbersome task. To overcome this the source code must be converted into the same machine language. For example, the source code of C++ is different for the different operating systems but the machine code is the same for all source codes developed on different operating systems.
Another method of developing a machine-independent program is converting source code into an intermediate language. This methodology is used in the .net framework and Java, in java the source code is converted into bytecode. This bytecode is an intermediate language. This intermediate code also called bytecode is executable on different computer hardware.
Earlier all the applications being developed were distributed as executable files and these executable files were binary files. The characteristics of these binary files are that they can be executed on the platform for which they are developed and can not be executed on a platform for which it is not made. To get executed on each type of platform there should be a separate binary for each platform. This is the case with the programming language C and C++.
Techniques of distributing Programs
There exist many techniques that can be used to distribute programs. These techniques include Hand Recoding, Automatic Machine Language-to-Machine Language Translation, Decompilation, and Meta-Assembly.
Hand-Recoding is the technique of rewriting the source code again.
Automatic Machine Language-to-Machine Language Translation is a technique in which a program developed using one language for a specific machine is converted into a program using a language that is compatible with another machine. The problem with this method is ambiguity. The program is translated into another language may take an extra or less amount of memory and it is possible that the execution time of the program may be more or less. It is also possible that the translated program may use registers inefficiently.
Decompilation is also a technique to distribute programs. In this process, the machine language program is converted back to compiler language the obtained code is again compiled as per the grammar of the language on the target machine. The problem with this method is that some of the machine language statements can not be converted into their equivalent compiler language statement. The decompilation process is highly dependent on the description of the data, the context in which the statement has been defined, and the information that is absent in the source code.
Meta-Assembly is another method to achieve platform independence. In this process, a meta assembler is used. The meta-assembler takes programming instructions consisting of symbols and parameters. These instructions are generated for the target machine. To distribute the program that should get executed on different computer hardware would require source code simulation on the specific machine.
Methods Hand Recoding, Automatic Machine Language-to-Machine Language Translation, and Decompilation are used to distribute programs that are in machine language. The Meta-Assembly method is used when a meta-assembler is available. If a meta-assembler is available then the source compiler language is made compatible with another machine language.
To develop platform-independent programs Delphi, Eclipse, Mono, OpenGL, ReNative, Unity, Unreal, etc can be used. The platform-independent programs must be executable on most of the computer hardware. To develop platform-independent programs the developers often use programming constructs that degrade the performance of developed software. The platform-independent programs must also address the issue of the user interface. The platform-independent programs must also address the issue of security.