Developing portable software



Download 370.21 Kb.
View original pdf
Page14/31
Date25.01.2021
Size370.21 Kb.
#55683
1   ...   10   11   12   13   14   15   16   17   ...   31
Mooney2004 Chapter DevelopingPortableSoftware (1)
5.4.3
Language Translation
5.5
Library Strategies
A compiler translates software from a human-oriented language to a language suitable for execution by machine. It is also possible to translate programs from one human-oriented language to another. If we are faced with a program written in a language for which we have no compiler for the target, and no prospect of obtaining one, then “source-to-source translation”
may be the best porting strategy available.
Translating software from Pascal to FORTRAN or C to Java is considerably more challenging than compiling, though not as difficult as natural language translation. Several tools are available which perform reasonable translations among selected languages. Usually these tools can do only an imperfect job translation must be regarded as a semi-automated process, in which a significant amount of manual effort maybe required.
Translation can also be used as a development strategy, when compiler variations are anticipated. Software maybe originally written in a higher- level language that can be translated into multiple languages or, more likely, language dialects, using a preprocessor. This is more likely to be a strategy that can be fully automated.
No programming language directly defines all of the resources and facilities required by a realistic program. Facilities that are neither defined within the language nor implemented by the program itself must be accessed explicitly through the environment. This access may take the form of procedure or function calls, method invocations, messages, program- generated statements or commands, etc. Whatever the mechanism, the aim is to obtain services or information from software and physical resources available in the environment.


70
James D. Mooney
These resources are organized into packages, collections, or subsystems that we may view uniformly as libraries. Examples may include language- based libraries such as C standard functions, scientific computation libraries,
graphic libraries, domain-specific classes and templates, mail server processes, network interfaces, or database management systems.
These libraries provide a class of interfaces, and programs that rely on them will be most portable if they are able to access these facilities in a common form. When this is not possible, adaptation will be required.
We must assume, of course, that the target systems are capable of supporting the services and facilities to which the libraries provide access.
No portability strategy can enable a program that plays music to run on a system that has no hardware support for sound!
Once again we can identify three classes of library strategies according to our three principal types standardize, port, translate. We will overview these strategies in the following subsections
Many types of library facilities are defined by formal or defacto standards. This group is led by libraries that are incorporated into specific language standards, such as the C standard function library, Ada standard packages, standard procedures and functions of Pascal, standard templates for C, etc. Software written in these languages should use the standard facilities as far as possible, taking care to distinguish what is actually standard and what has been added by a particular language implementation.
Additional standard library facilities are not bound to a specific language but are widely implemented in many environments. This is especially likely for libraries providing services of broad usefulness. Some examples here include GKS libraries for low-level graphics functions, MPI for message passing, CORBA for distributed object access, or SQL for database access.
Portable software may rely on such libraries if they are expected to be widely available, but must make use of an alternate strategy when they are not.
If the absence of a library supporting an important standard is a major drawback for the target environment, it maybe worthwhile to consider implementing such a library. This is likely to be a major effort but could significantly improve the target environment as well as aiding the immediate porting project.

Download 370.21 Kb.

Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   31




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

    Main page