What is Portability?
Portability is the ability to be easily carried or moved. In programming, Portability represents the ability of software to be transferred from one platform to another. Almost all high level languages such as C, C++, Java etc are portable i.e. Their applications can be executed on all platforms.
How a language is made Portable?
A language is made portable by providing its compilers or runtime environments for all the platforms. E.g. C is portable because its compilers are available for all the platforms such Windows, Unix, Mac etc. Similarly Java is portable because its runtime environment JRE is available for all the platforms.
What is Platform Independency?
If a language doesn’t have any dependency on a platform then it is called Platform Independent. A language has following three dependencies on a platform:
Dependency of Compilation:
Compilation is a translation process in which instructions of a high level language are translated into machine understandable instructions. In order to create a compiler, source instructions set, target instructions set, and a file format are required. Before Java, target instruction set and file format were provided by O/S vendors i.e O/S specific compilers were made.
Dependency of Execution:
If an application is executed by the O/S it must have O/S specific format and instructions. Such execution is called platform dependent execution.
Dependency of Resources:
Each application need some resources such as input/output devices, access to file system, network ports etc. All these resources are controlled by the O/S. If an application directly invokes O/S functions to use these resources the application need to be modified when the O/S is changed because all O/S don’t provide same functions for the resources.
Difference between Portability and Platform Independency?
If a language is portable it means that its applications can be executed on all platforms. If a language is platform independent then it means that its applications don’t have any dependency on any O/S.
On the basis of Portability and Platform Independency, languages can be divided into following categories: