More rants and raves will be added as they crop up (they have - lots. Hack) (if time ever becomes available. Ed)
There are inevitably some system-dependent
calls somewhere or other - for example, when accessing the command parameters
of the program, spawning external processes, setting and executing condition
handlers, accessing environment variables and so forth. By wrapping as
many of these as possible up into a Run-Time Library, much grief can be
avoided when migrating to another platform as the changes need only be
put into the library. Similarly, actions involving the external file system
(such as creating and/or opening files) and the flow of execution are also
best done via library routines so that a change of platform (and
the consequent changes in directory structure, default file attributes
etc) can be taken account of in one go.
Unfortunately, there can be system-specific things which might supervene - for example, the DEC (FORTRAN) need for a condition handler to be set by calling LIB$ESTABLISH in the top segment of its scope; but these can be minimised. When dealing with multiple-platform FORTRAN code under VMS, one trick is to prefix the DEC-only lines of code with 'D' and the non-DEC lines with 'C' (comments are then prefixed with '!'), and to use the /D_LINES compiler option. When porting the code, strip off the 'C's (using a simple program) - if necessary, the 'C's can be followed by further switch character(s) for the porting program to act on. One soon gets used to the extraneous lines of code and it is very useful to see them all together when amending the program.
A run-time library needs to be nurtured and becomes part of a lifetime's tool-kit (or baggage).
Having read in the entire file (or as large
a chunk at a time as possible), the data can be indexed and written out
in a form that can be used much more quickly next time, having checked
that the original has not been altered in the meantime. If it has, the
user probably won't mind waiting (probably no longer than a 'regular load-and-reorganisation'
would have taken anyway) whilst the fast-access file is 'quickly' rebuilt
- provided, of course, that a polite explanation appears whilst that is
happening. A couple of easy ways to improve the pace of life are (1) binary
storage and (2) pre-sorting.
Consequently, a compact (binary) format was devised which is in use to this day and, under GALAXY, most graphics is still a two-step process: there is a universal Graphics Library to which programs are linked; when the program is run, it creates a compact metafile which is then plotted/printed, or viewed on the screen, by issuing a second command which typically generates a huge tranche of PostScript and sends it to the laser printer, or whatever.
Nowadays, the advantages and disadvantages of having the generating program send graphics to the printer immediately or instead to store its output in a file until deliberately printed by the user have almost converged. However, in the interests of forest management, it is usually preferable to give yourself a moment's pause to ask 'do I really need to print this, or am I just after something else that comes out of the program?' before wasting yet another fractional tree.
Some other advantages of the two-step process include being able to store plots electronically in compact form and, when a sensational new output device comes along, it being unnecessary to re-link (or, worse, to alter) and attempt to re-run all those old programs - the new driver is just added to the universal display/plotting/printing program.
From a hacker's perspective, style prejudices
apart, one is usually hugely relieved when an alien program can be compiled
and then works correctly. Looking at samples that have produced the 'Thank
God' factor in the past, such programs seem to have in common:
[Return to Hackers' Corner]
[End of document, updated to 17 March 1997]