It is a long-term goal of some engineering sciences to achieve self-replication in a material device. Nanotechnologists in particular believe that their work will likely fail to reach a state of maturity until human beings design a self-replicative assembler of nanometer dimensions. Merely exploiting the replicative abilities of existing cells is insufficient, because of limitations in the process of protein biosynthesis (also see the listing for RNA). What is required is the rational design of an entirely novel replicator with a much wider range of synthesis capabilities. For a discussion of other chemical basis for hypothetical self-replicating systems, see carbon chauvinism.
A fully novel replicator is, however, a fairly long-term goal. Given the currently keen interest in biotechnology and the high levels of funding in that field, attempts to exploit the replicative ability of existing cells are timely, and may easily lead to significant insights and advances. It may also be practical to attempt to build a self-replicating machine of a more conventional size, elsewhere called a clanking replicator.
In computer science a self-replicating computer program is a computer program, that, when executed, outputs its own code. Here is an example program in the Python programming language:
Example of a self-replicating computer program
import string
def eniuq(s):
print s + "\\neniuq (\\"" + string.replace(string.replace(string.replace(s,"\\\\","\\\\\\\\"),"\\"","\\\\\\""),"\\n","\\\\n") + "\\")"
eniuq ("import string\\ndef eniuq(s):\\n print s + \\"\\\\neniuq (\\\\\\"\\" + string.replace(string.replace(string.replace(s,\\"\\\\\\\\\\",\\"\\\\\\\\\\\\\\\\\\"),\\"\\\\\\"\\",\\"\\\\\\\\\\\\\\"\\"),\\"\\\\n\\",\\"\\\\\\\\n\\") + \\"\\\\\\")\\"")
A more trivial approach is to write a program that will make a copy of any stream of data that it is directed to, and then direct it at its own self. In this case the program is treated as both executable code, and as data to be manipulated. This approach is common in most self-replicating systems, including biological life, and is simpler in that it does not require the program to contain a complete description of itself.
References
See also: virus, complex systems, artificial life (ALife)