Developing portable software



Download 370.21 Kb.
View original pdf
Page12/31
Date25.01.2021
Size370.21 Kb.
#55683
1   ...   8   9   10   11   12   13   14   15   ...   31
Mooney2004 Chapter DevelopingPortableSoftware (1)
5.3.3
Translate the Interface
5.4
Language Based Strategies
If the interfaces do not match, elements on one side maybe converted into the equivalent elements on the other. This maybe done by an overall translation process when porting, or by providing extra software that interprets one interface in terms of the other during execution.
An example of the first variation is the usual compiling process. The common representation for the architecture interface of a program (in the source language) is translated to the specific architecture of the target. The second variation is illustrated by a library that converts one set of graphics functions to a different set provided in the target environment.
This strategy maybe planned during development but must be carried out in the context of a specific implementation.
There is one alternative to all these approaches that is to redesign the software to fit the interface of the target environment. This is not a portability strategy, but an alternative to porting. Sometimes this is the best alternative, and we must know how to make a choice. This issue will be discussed later.
We now are prepared fora look at the various strategies associated with each of the main classes language, library, operating system, and architecture.
Effective approaches to portable design start with the choice and disciplined use of a suitable programming language. If the language allows a single expression of a program to be understood identically in all target environments, then portability will be achieved.
In practice, it is very often possible to express many of a program’s requirements in a common language, but not all of them. If the language includes no representation for certain concepts, they must be handled by other strategy classes.
Sometimes the language in which the program is currently expressed is not supported for the target environment. In this case it becomes necessary to translate the software from one language to another.
The source language representation of a software unit is the most convenient starting point for both manual adaptation (e.g. editing) and automated adaptation (e.g. compiling) to prepare it for use in a given target


68
James D. Mooney
environment. Therefore language-based strategies are the single most essential class in our collection.
Language strategies for portability maybe classified according to the three types identified in the previous section standardize, port, translate.
Programming languages were among the first types of computer-related specifications to be formally standardized. Today formal standards exist for over a dozen popular general-purpose languages, including FORTRAN,
COBOL, Ada, Pascal, C, and C+ (note that standardization for Java is not yet achieved).
Writing a program in a standard language is an essential step in achieving portability. However, it is only a starting point. The language must be one that is actually available inmost expected target environments. No standard is clear, complete and unambiguous in every detail, so the programmer must follow a discipline (think portable) that avoids use of language features which may have differing interpretations. No language covers all of the facilities and resources that particular programs may require, so portability in some areas must be achieved by other means.
Effective use of standard languages is crucial to achieving portability.
Each of the most widely-used languages presents a somewhat different set of opportunities and problems for effective portable programming. For example, C does not fully define the range of integers many Java features continue to vary as the language evolves. Standard language strategies, and the issues raised by specific languages, are often the subject of books and are beyond the scope of this paper.
One of the potential problems of the use of standard languages is the fact that different compilers may use different interpretations in areas where the standard is not completely clear. If the same compiler is used for each target environment, then its interpretation of a software unit will not vary, even if it is non-standard!
To exploit this situation, we may choose to write a program fora specific compiler, then port the compiler to each new environment. Porting the compiler, of course, maybe a daunting task, but it needs to be done only once to make all software for that compiler usable on the new target. Thus the payoff maybe great, and if we are lucky, someone has already done it for us.

Download 370.21 Kb.

Share with your friends:
1   ...   8   9   10   11   12   13   14   15   ...   31




The database is protected by copyright ©ininet.org 2024
send message

    Main page