On Mar 22, 2018, at 7:53 PM, Doug McIlroy <doug(a)cs.dartmouth.edu> wrote:
"The only thing I can think of is to use have programs that
translate programs in todays languages to a common but very
simple universal language for their "long term storage". May
be something like Lamport's TLA+? A very tough job.
"
Maybe not so hard. An existence proof is Brenda Baker's "struct",
which was in v7. It converted Fortran to Ratfor (which of course
turned it back to Fortran). Interestingly, authors found their
completely reorganized code easier to read than what they had
written in the first place.
Her big discovery was a canonical form--it was not a matter of
taste or choice how the code got rearranged.
It would be harder to convert the code to say, Matlab,
because then you'd have to unravel COMMON statements and
format strings. It's easy to cook up nasty examples, like
getting away with writing behyond the end of an array, but
such things are rare in working code.
I can believe that for Fortran but for C/C++ or other such
less well defined languages this may be much harder. Far
easier to write an emulator for x86 and that is fine if all
you want to do is run the same old compiled program but if you
want to make changes, de-compiling x86 code to something
structured would be much harder. Compiling the original code
to a multi-paradigm language such as Scheme or Lisp may be
another alternative....
[Aside:
Thanks for mentioning the name of this program as I had
forgotten it. I used "struct" once to convert a Fortran
program to Ratfor and then manually to C. This was for
programming PALs and we wanted to make some local changes.
IIRC, this was back in '82, back when vendors gave you
programs with sources for their devices, unlike the Xilinx &
Altera of today who don't even publish bitstream formats used
to program their devices.]