Portable Self-Replicating C Contest

Todd M. Lewis utoddl at ecsvax.UUCP
Mon Mar 27 23:42:39 AEST 1989


In article <9929 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> In article <1417 at sw1e.UUCP> uucibg at sw1e.UUCP (Brian Gilstrap [5-3929]) writes:
> >It seems that it would be impossible to create a program which generates it's
> >source as output because you have a self-referential system and will end up
> >with an infinite recursion.
> 
> Nope.  If you try to make that line of reasoning precise you'll find
> gaps in the logic.  In fact self-replicating systems can be quite small.
> Self-reference need not imply infinite recursion, and self-replication
> need not imply self-reference.

That's a bit theoretical.  If it doesn't convince you, try
thinking about it this way.  Most programs that will be submitted
will use some form of put or printf call, yet the source to
printf will not be printed.  The point is that it could be.
Think of the token "printf" as expanding to the entire source
to printf.  The program would still work, but the string produced
by the program would have to be longer.  That may make it more
tricky, but not any harder, er, theoretically.  Note also that this
printf need not use the OS, but could go right to the hardware
so that it could work without any OS at all.  (How it would have
gotten into the machine is another question.)
   Now that the magic is done, consider this: this program will
only work on specific hardware.  You have to consider this because
each op-code is in fact "expanded" to the hardware design that
supports it, just as printf is expanded on a higher level.  Programs
can only reproduce themselves in a suitable environment.  (That goes
for lizards, fish, people, and other self-replicating systems.)
   So work back from this perspective to our self-replicating
program and you will see that the OS and library routines and
the hardware all work together to create an environment in which
our programs can "live" (dont take this too far..) and in which
some programs can reproduce.
   You are right in thinking that programs can't really reproduce
without some greater reference capabilities.  Self-replicating
systems rely heavily on building on the structure of their
environments, whether that means computer op-codes and address
spaces or atoms and the Universe.  The "meaning" of our programms'
op-codes derives from the hardware.

   Now, about that entropy thingy ... :)

  _____        
    |      Todd M. Lewis            Disclaimer: If you want my employer's
    ||\/|  utoddl at ecsvax.uncecs.edu             ideas, you'll have to
    ||  ||                                      _buy_ them. 
     |  ||     
         |___   (Never write a program bigger than your screen.)



More information about the Comp.std.c mailing list