Although there aren’t so many modern computing systems (Windows, Apple Macintosh and iOS, the Linux family, and Android to name a few), they are very diverse, sharing few common base systems. Add to this the differences in hardware, especially different processors, the problem of writing code to run in these environments becomes worse.
Portability means an application can run properly on a different platforms with little or no modification. If modification is needed, the task of modifying the software to allow it to run in the new environment is known as porting. How complex these modifications are depends not only on the hardware, but also how well the software was written (usability) in the first place.
For a long time a goal of programming has been to ‘code once, run everywhere‘.
In order for any higher level language code to be run by the processor it must be converted into the machine code that the particular processor understands.This also applies to other computer hardware that do their own processing, eg modern graphics cards
The Compiler
The name “compiler” is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g. assembly language, object code, or machine code) to create an executable program (Wikipedia)
Compilers take the source code and convert it into an executable program the operating system can run. This is done in advance by the developer, with the final executable (eg .exe) being shipped to the end user.
One solution for portability is to make a large number of different compilers for every possible hardware platform. Many hardware systems are written in C and there are many different compilers available to choose from. The developer must still bear in mind the target system in case of specific advantages or disadvantages the system may have.
JAVA
JAVA represents a completely different approach. Here a suitable Java Virtual Machine (JVM) is installed on the target system and this virtual machine runs the java program, literally running the raw code written by the developer. The JVM contains a special just-in-time compiler that passes the executable to the operating system.
Consequently the developer has only to focus on the code, not the target machine, when writing code, as the JVM will handle the target system peculiarities. This way one code can run on various types of system without needing any changes!
Find examples of compiled programs that could be installed on a computer system (including mobile systems)
Find examples of JAVA programs that could be installed on a computer system
Hint: these programs could be online available to download!