Wednesday, January 19, 2011

Software portability

Portability is one of the key concepts of high-level programming. Portability is the software codebase feature to be able to reuse the existing code instead of creating new code when moving software from an environment to another. The prerequirement for portability is the generalized abstraction between the application logic and system interfaces. When one is targeting several platforms with the same application, portability is the key issue for development cost reduction.

This article is about preparing software for being optimally portable. The work required when the portability is found to be insufficient, is described in the article Porting.

Contents

[hide]

[edit] Strategies for portability

Software portability may be achieved on three different levels:

  • Installed program files may be transferred to another computer.
  • The program may be reinstalled (from the distribution files) on another computer.
  • The source files may be compiled for another computer.

These alternatives were ranked for decreasing user-friendliness, and hence decreasing system quality ambition.

Which of these user-friendliness levels is obtainable, depends on the degree of similarity between the systems ported between.

[edit] Similar systems

When the same operating system version is installed on two compatible computers, it is often possible to transfer one or more program files between them, but the software will generally have to be prepared in a special manner: It must be decided which program libraries can be assumed to exist on the target computer, and which must be included with the application package. A portable application intended to run from a USB stick demonstrates this ultimate portability. It is designed to leave no traces on the computer it is installed on. This property is not required for the present situation, when the program is supposed to remain on this computer. But if the program is self-contained in e.g. its own directory, it will be easier to port it on to a third system.

[edit] Different operating systems, using similar processors

When the systems in question are using similar processors (in practice: x86-compatible processors), they will execute the low-level program instructions in the same manner, but the system calls are likely to differ between different operating systems. New operating systems of UNIX heritage — including Linux, BSD, Solaris and MacOS X – are able to achieve such software portability by using the POSIX standard for calling OS functions. Such POSIX-based programs can be used in Windows by means of interface software such as Cygwin.

[edit] Different processors

Many people write programs that require the Intel-compatible 32 bit x86 instruction set, even though there is another instruction set architecture used by more 32 bit CPUs. It is mainly for the smallest (pocket-sized) computers that alternative processors, such as ARM architecture, are used, but these are generally thought to require less sophisticated programs. Web applications are required to be processor independent, so using web programming techniques is a popular method for achieving portability, and this programming strategy is convenient, even when quite similar systems are targeted. The program can then be written in JavaScript, which can run in a common web browser, which may now be assumed to have a Java package containing the Java virtual machine and its Java Class Library. Such web applications must, for security reasons, have limited powers on the host computer, especially when it comes to reading and writing files. Non-web programs, installed upon a computer in the normal manner, can have full powers, and yet achieve system portability by linking to the Java package. By using Java bytecode instructions instead of conventional processor dependent machine code, maximum software portability is achieved. This doesn't mean the programs have to be written in Java, as compilers for several other languages can generate Java bytecode: Jruby does it from Ruby programs, Jython from Python programs, and there are several others.

[edit] Recompilation

Porting a program by compiling and linking it again is a valid portability strategy if the porting is to be done by programmers, and the need for porting by users is disregarded. It is then wise to write the program in a programming language for which there are compatible compilers on the interesting platforms.

It is possible for users to port software in this way if the source code is available to them, but this will normally be a demanding procedure, except for technically advanced users. An automated compile/link, using a Make tool, is in principle a simple procedure, but when something goes wrong, the error messages from a compiler or linker are likely to be too demanding for the end users. Some Linux distros distribute software to their users in source form, but it may then be assumed the users are running at least the same Linux distro.

[edit] See also

[edit] Sources

No comments:

Post a Comment