84 Comments
- sundancekid503, on 10/12/2007, -2/+43Can you insert comments so your code is more readable please
- plamoni, on 10/12/2007, -3/+35I think it sounds interesting. In fact, what might be really interesting is to write a quine that does the following:
- makes a random modification to it's data portion
- outputs itself to a file
- compiles/executes that file
- checks to see if the "child" compiles, if not, repeats the process
- if the "child" does compile, it deletes itself.
What you would be left with would be a series of "evolving" programs. In all likelihood, the "new" programs would be the same but with different comments. But once in a long while (or short while with a fast enough computer), you would get a new command added. There is probably more to it, (you would probably need to create several children for each parent, but it would be really interesting to see what the code evolves into, with no human interaction. - y2048, on 10/12/2007, -0/+26The smallest possible self-replicating program won in the 1994 International Obfuscated C Code Contest
http://www.ioccc.org/1994/smr.hint
I've included its source code below: - Urusai, on 10/12/2007, -2/+20"Yow! I've just lost the SOURCE CODE for all my QUINE PROGRAMS! What will I DO NOW with just the BINARIES?"
LOL, computer science humor. - dasil003, on 10/12/2007, -4/+22The point is to expand your mind. Particularly important in this day and age when 'programmers' spend their whole life coding in one language like Java or PHP and don't understand any of the deep concepts that make those languages possible.
- benhocking, on 10/12/2007, -2/+9Here's a fairly simple one in C:
-----
#include
int main() {
const char *x = "#include %cint main() {%c const char *x = %c%s%c;%c printf(x, 10, 10, 34, x, 34, 10, 10, 10);%c };%c";
printf(x, 10, 10, 34, x, 34, 10, 10, 10);
};
-----
Depending on how well this imports, you might need to run it once to get the correctly formatted code. From then on the copies will definitely make accurate copies of themselves. - merreborn, on 10/12/2007, -6/+13"I'm sick of slow apps written poorly, usually in Java that require my machine to be clocked at 3Ghz with 2 gig of ram just to do what my old 486 used to do in 1995."
It leads one to wonder where all those cycles go. The answer? Tools like Java make it possible for a single developer to do what it would have taken a whole team to do in '95. Yes, it requires more hardware, but the software can be developed for a fraction of the cost. - Angostura, on 10/12/2007, -1/+8In Basic:
10 List - MikeWeller, on 10/12/2007, -1/+8My brain hurts.
- Adoozie, on 10/12/2007, -5/+11Take a course in AI and you'll realize how incredibly wrong you are. Quines aren't at all an example of "learning".
- brhad56, on 10/12/2007, -1/+7If you would have RTFA, "The easiest way to do that, of course, is to seek the source file on the disk, open it, and print its contents. That may be done, but it is considered cheating; besides, the program might not know where the source file is, it may have access to only the compiled data, or the programming language may simply forbid that sort of operations."
- chasebase, on 10/12/2007, -1/+6This is related to one of the most important problems in mathematics, Godel's* Incompleteness Theorem. Essentially, a quine shows us how a program can refer to itself without saying "I" directly -- that trick, in a different form, is a basis of Godel's proof.
*(There should be an umlat over the 'o' in Godel, but I have no idea how to make one). - siliconglen, on 10/12/2007, -2/+6A quine is also a Scottish word from the north east of Scotland meaning a young girl. A young boy is a 'loon'. So there you go.
- gaberbruno, on 10/12/2007, -1/+4A "quine" is also a Scots term for a girl or lady, the equivilent term for a male would be a "loon" - absolutely nothing to do with self replicating programmes, just thought I'd share it with my fellow diggers!
- brian6String, on 10/12/2007, -2/+5Being non-trivial to implement doesn't mean it's still not stupid or pointless.
- Flooq, on 10/12/2007, -5/+8Doesn't it just loop and replicate itself? That sounds closer to a crazy guy muttering to himself than someone learning.
- jmccorm, on 10/12/2007, -2/+510 LIST
20 END - brhad56, on 10/12/2007, -6/+9RTFA
- brix, on 10/12/2007, -1/+3@plamoni
Sounds like Tierra -- If this wasn't a recent Digg, it was a recent del.icio.us favorite.
http://www.infidels.org/library/modern/meta/getalife/coretierra.html - n00854180t, on 10/12/2007, -1/+3If the universe is indeed a massive quantum computer that computes existence, it would have to be a quine.
- Electric_Sheep, on 10/12/2007, -3/+5In Scotland, or Aberdeenshire/Aberdeen specifically, a "quine" is the name given to a fisherman's wife. Which has become part of the mainstream of the city, in which, and any woman, or girl is a "quine.
As i use quite frequently. "Fit ye lyke, silly auld quine"
:D - eurleif, on 10/12/2007, -3/+5If cheating is allowed, you can do it with even simpler code: "". Don't include the quotes.
- trogdor282, on 10/12/2007, -1/+3tierra i think that your algorithm would quickly die of 'infertility', that is a program that compiled but was unable to quine itself over thousands of attempts. interesting to think about, though.
there IS interesting stuff like that out there, but afaik it all uses neural nets or something else much less strict than c. - fuzzmello, on 10/12/2007, -1/+2see kleene's recursion theorem - http://en.wikipedia.org/wiki/Kleene%27s_recursion_theorem
- ctech2k, on 10/12/2007, -1/+2The ultimate Quine...if Alan Guth is right, we build a universe in the lab. For it to work, we have to be "wrong" about some things (e.g. that the universe IS fundamentally deterministic, with a reproduceable-by-humans set of "startup parameters"), but perhaps we could make a universe guaranteed to evolve into an exact copy of our own (which would then produce yet another universe like our own...)---this would be a Quine-analog that produces, then runs, a copy of itself.
- imnewtryme, on 10/12/2007, -1/+2Tip: Its a great SCRABBLE word I've thrown out a few times :)
- dongiaconia, on 10/12/2007, -3/+4Then you should check out Prolog.
- noamsml, on 10/12/2007, -3/+4In PHP it should be easy enough:
[?php
echo file_get_contents(__FILE__)
?]
In compiled languages it shoud be pretty hard. - guitarromantic, on 10/12/2007, -2/+3But will it run on Linux?
- munkt0n, on 10/12/2007, -2/+3Quine, Bobby
legendary console cowboy, also the teacher of Case. He burnt the 'House of the Blue Lights' with his partner Automatic Jack. - directorblue, on 10/12/2007, -1/+2Here's one in PHP without using the file system...
http://directorblue.blogspot.com/2004/05/self-reproducing-code-i-was-reading.html - ccheath, on 10/12/2007, -1/+2also doesn't mean it is, either...
- LucasOman, on 10/12/2007, -3/+4Go watch Teletubbies and leave the intellectual pursuits to the adults.
- 5blocksfree, on 10/12/2007, -1/+2@merreborn
Perhaps, but one thing I've noticed about OOP is that since abstraction is the name of the game, you have layers upon layers of abstraction- where once you might have a simple function to accomplish a fairly straightforward (albeit tighlty-coupled) task, now you've got any number of interfaces, classes, subclasses, and/or frameworks involved- all to abstract the programmer away from what's actually being done. While it may very well save time, it imposes another cost in the amount of overhead that is required. - nuxx, on 10/12/2007, -1/+1nice neuromancer ref...that was my immidiate thought too!
"...I met Quine once, Real *****..."
- Molly Millions - brandonr, on 10/12/2007, -3/+3Well, the rest of my work day is completely shot. Thank you digg.
- shinynew, on 10/12/2007, -1/+1already been said, do a quick ctrl-F loon to find that out.
- aoeuhtns, on 10/12/2007, -1/+1this is exactly was this neat program did back in 1988
http://world.std.com/~franl/worm.html (was on the frontpage) - rspeed, on 10/12/2007, -1/+1@eurleif:
Nice try, but "" != NULL - Urusai, on 10/12/2007, -2/+2Then you construct a logical statement saying "[I] am false", and once again Spock defeats the evil computer with his uber logic.
- doghand, on 10/12/2007, -2/+2xopl, you're an idiot. a virus can duplicate itself. This is a trivial process. It is difficult to output precicely the code that is doing the outputting and this would be a stupid way to write a virus. This is not at all like virus writing. You were burried because you completely misunderstood. Next read the article or try harder to not be stupid
- willcode4beer, on 10/12/2007, -1/+1"The point is to expand your mind. Particularly important in this day and age when 'programmers' spend their whole life coding in one language like Java or PHP and don't understand any of the deep concepts that make those languages possible."
Very true, however, it can be done in Java as well
class Q{public static void main(String[]v){char c=34;System.out.print(s+c+s+c+';'+'}');}static String s="class Q{public static void main(String[]v){char c=34;System.out.print(s+c+s+c+';'+'}');}static String s=";}
Blatantly ripped off from:
http://www.knet.ro/lsantha/ - InternetUser, on 10/12/2007, -2/+2Yeah I've done this, it's quite fun :)
- GazzleLuigi, on 10/12/2007, -1/+1Dinnae get me hamesick. Och, I fair miss Aitkin's rowies. Ye jist cannae beat 'em.
- M2Ys4U, on 10/12/2007, -1/+1plamoni:
http://progranism.com self-replicating and modifying programs - kabz, on 10/12/2007, -2/+2I know. Fit's ga'en on? First the Aitken's rowies, then quines. Is Digg bein' taken' ower by Aberdonians?
Far's the paper? - stormist, on 10/12/2007, -1/+1They are already using the technique to program Duke Nukem Forever
______________________
quoting: plamoni
I think it sounds interesting. In fact, what might be really interesting is to write a quine that does the following:
- makes a random modification to it's data portion
- outputs itself to a file
- compiles/executes that file
- checks to see if the "child" compiles, if not, repeats the process
- if the "child" does compile, it deletes itself.
What you would be left with would be a series of "evolving" programs. In all likelihood, the "new" programs would be the same but with different comments. But once in a long while (or short while with a fast enough computer), you would get a new command added. There is probably more to it, (you would probably need to create several children for each parent, but it would be really interesting to see what the code evolves into, with no human interaction. - inactive, on 10/12/2007, -3/+3:) yes i should have elaborated on the compiled part. good point.
- speedmaster, on 10/12/2007, -2/+2I've seen a few of these done in 'C', they kind of freak me out. ;-)
- PaulOwen, on 10/12/2007, -1/+1@Urusai
Your quote is taken from the article (near the bottom).
And people digg it anyway because they haven't RTFA - haha. I think I'll digg your comment too. -
Show 51 - 84 of 84 discussions

What is Digg?
Browsing Digg on your phone just got easier with our enhancements to the