Portability vs Platform Independency

In this post, you will learn:

  • What is Portability?
  • What is Platfrom Independency?
  • What is the difference b/w Portability and Platform Independency?

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:

  1. Dependency of Compilation.
  2. Dependency of Execution.
  3. Dependency of Resources.

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.

For Example:

When a C program is compiled by Turbo compiler, C instructions are translated into DOS function calls and are stored in a exe format file. Such a file can only be executed on DOS or Windows. To execute the same program on Unix/Linux, it need to be compiled again by CC/GCC compiler which generates object code for Unix/Linux.

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.

A platform independent language satisfies following conditions:

  • It is compiled in a platform independent manner i.e. when the platform is changed its source code isn’t recompiled.

  • The language provides its own runtime environment for the execution of its applications i.e. its applications are not executed by the O/S.

  • It provides a comprehensive library to make all the system resources available to the applications i.e. its application don’t need to interact to the O/S to use system 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:

1. Portable but not Platform Independent

C and C++ are the examples of this category. They are portable because their compilers are available for all the platforms but they are not platform independent.

2. Platform Independent but not Portable

.Net is the example of this category. .Net is Platform Independent but it is not portable because .Net Framework is not available for all the platforms i.e. .Net applications don’t run on all platforms.

2. Portable as well as Platform Independent

Java is the example of this category. Java is Platform Independent as well as portable because its runtime environment JRE is made available for all platforms i.e. its applications run on all platforms.

Its time to recap the main concepts:

  1. If applications of a language can be executed on all the platforms then the application is called Portable. Portability is achieved by providing compilers or runtime environments of the language for all the platforms.
  2. If applications of a language don’t have any dependency on any O/S then the language is called Platform Independent.
  3. A language may be Portable or Platform Independent or both.
If you like the post, then share it...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *