[comp.lang.fortran] Portability/Standard Conforming/Giles

fouts@lemming.nas.nasa.gov.nas.nasa.gov (Marty Fouts) (09/24/88)

Giles is trying to have it both ways again.  He is using 'standard
conforming' when it supports his point of view and 'portable' when it
supports his point of view, and responding to arguments against his
'standard conforming' arguments with 'portable' rebutables.  For the
protection of the innocent, I am about to make some specific comments
about standard conforming and portable:

1) Standard conforming:  "You want a standard?  WE've got lots of
   standards." 

There are in the universe three kinds of standards:

  A) 'Official'  Some group of people decide adopt a document
     as a standard.  This can be a government agency such as
     ANSI or an industry group such as IEEE

  B) 'Defacto'  Nobody every specified a standard, but there is
     a common approach to doing things and if you use the common
     approach you will win most of the time.  Before microprocessors
     this was true of C, since almost all C compilers were ports
     of Johnson's pcc, so they had very similar semantics.  Thus,
     pcc/K&R became the 'Defacto' C standard.

  C) 'Pragmatic'  There ain't no standard, but I've got to get this
     job done, so I'll make up my own which will consist of the union
     of common features.  My personal standard for portable Fortran,
     for example, which takes into account the number of machines I
     have to write Fortran on which don't (or didn't until very
     recently) have ANSI 77 Fortran compilers.


2) Portability:  There are lots of definitions of portability.  The
original one I heard was less effort to take this code and make it
work on a new machine than to write the code for a new machine.  This
suggests to me that 'degree of portability' is probably the best
phrase.

Standard-Conforming DOES NOT EQUAL Portable.

It is possible to write in any language which allows implementers to
make any implementation decisions a program which is standard
conforming and not portable and a program which is portable and not
standard.

As an exercise:  Go to the standard specification for your favorite
language.  Find a place where it says words to the effect "semantics
left to the implementer".  Figure out how to write a perfectly
conforming program which may give different results on different
systems.  This program is standard conforming and nonportable.

As a second exercise:  Find a feature not specified in your favorite
programming language standard which is available in the implementation
on some largish number of machines.  Write a program which uses this
feature.  This program is not standard conforming, but has a high
degree of portability to those machines.

Pragmatism:

A certain supercomputer I use doesn't have an ANSI Fortran 77
Compiler.  Another one does, but it produces bad code, so that I have
to use a different compiler on the machine which is vendor specific
Fortran and not ANSI 77.  A third one didn't until about a year ago,
so before that I didn't have an ANSI compiler for it either.  Similar
comments apply to other machines I use.  Very few systems I write code
for have ANSI compliant Fortran compilers which aren't broken in some
painfully visible way.

I care that my code is efficent, I care that it has a high degree of
portability.  I haven't seen enough standard conforming compilers to
care about.  So I think about the appropriate subset of the language
that will give my code a high chance of running.  The standard is not
my guide.

The same is true of my C code.  *MOST* of the compilers I write for
are PCC derived, so that gives me some comfort.  Few of the machines I
write for have the same word size, byte ordering, parameter passing
mechanisms, memory organization as each other, so I carefully write
portable code.  Surprising (to those who don't do it,)  these kinds of
problems just aren't problems for a careful programmer.

I face the same kinds of problems porting C that I face porting
Fortran.  I have ported extensive amounts of code in both languages
and they both give me about the same grief in about the same way:

1) Features I could use that aren't there
2) Features that are broken in one or more of the
   implementations I have to deal with.
3) Environmental issues (OS/Run time environment)
   that aren't addressed by the language.

Fortran gives me more kinds of problems in writing portable code for
the kinds of applications I write in all three of these areas.  If you
do different kinds of code, I suspect you'll see different kinds of
problems.  I could even describe the kind of applications where C
would give more problems than Fortran.

I just can't see either sides claim that language alpha is more
portable than language beta.

Marty
-- Whose been there and lived to tell about it.
+-+-+-+     I don't know who I am, why should you?     +-+-+-+
   |        fouts@lemming.nas.nasa.gov                    |
   |        ...!ames!orville!fouts                        |
   |        Never attribute to malice what can be         |
+-+-+-+     explained by incompetence.                 +-+-+-+