Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Quine (computing)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Example=== This Java program outputs the source for a C++ program that outputs the original Java code. <!-- NOTE TO EDITORS: The following code is very fragile. If you edit it, be very careful not to break it -- verify that the output of the Java program is identical to the C++ program, and that the output of the C++ program is identical to the Java program. --> <div style="width: 49%; overflow: auto; float: right; padding-left: 1%;" > <syntaxhighlight lang="cpp"> #include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { char q = 34; string l[] = { " ", "=============<<<<<<<< C++ Code >>>>>>>>=============", "#include <iostream>", "#include <string>", "using namespace std;", "", "int main(int argc, char* argv[])", "{", " char q = 34;", " string l[] = {", " };", " for(int i = 20; i <= 25; i++)", " cout << l[i] << endl;", " for(int i = 0; i <= 34; i++)", " cout << l[0] + q + l[i] + q + ',' << endl;", " for(int i = 26; i <= 34; i++)", " cout << l[i] << endl;", " return 0;", "}", "=============<<<<<<<< Java Code >>>>>>>>=============", "public class Quine", "{", " public static void main(String[] args)", " {", " char q = 34;", " String[] l = {", " };", " for(int i = 2; i <= 9; i++)", " System.out.println(l[i]);", " for(int i = 0; i < l.length; i++)", " System.out.println(l[0] + q + l[i] + q + ',');", " for(int i = 10; i <= 18; i++)", " System.out.println(l[i]);", " }", "}", }; for(int i = 20; i <= 25; i++) cout << l[i] << endl; for(int i = 0; i <= 34; i++) cout << l[0] + q + l[i] + q + ',' << endl; for(int i = 26; i <= 34; i++) cout << l[i] << endl; return 0; }</syntaxhighlight> </div><div style="width: 49%; overflow: auto; float: left; padding-right: 1%;" > <syntaxhighlight lang="java">public class Quine { public static void main(String[] args) { char q = 34; String[] l = { " ", "=============<<<<<<<< C++ Code >>>>>>>>=============", "#include <iostream>", "#include <string>", "using namespace std;", "", "int main(int argc, char* argv[])", "{", " char q = 34;", " string l[] = {", " };", " for(int i = 20; i <= 25; i++)", " cout << l[i] << endl;", " for(int i = 0; i <= 34; i++)", " cout << l[0] + q + l[i] + q + ',' << endl;", " for(int i = 26; i <= 34; i++)", " cout << l[i] << endl;", " return 0;", "}", "=============<<<<<<<< Java Code >>>>>>>>=============", "public class Quine", "{", " public static void main(String[] args)", " {", " char q = 34;", " String[] l = {", " };", " for(int i = 2; i <= 9; i++)", " System.out.println(l[i]);", " for(int i = 0; i < l.length; i++)", " System.out.println(l[0] + q + l[i] + q + ',');", " for(int i = 10; i <= 18; i++)", " System.out.println(l[i]);", " }", "}", }; for(int i = 2; i <= 9; i++) System.out.println(l[i]); for(int i = 0; i < l.length; i++) System.out.println(l[0] + q + l[i] + q + ','); for(int i = 10; i <= 18; i++) System.out.println(l[i]); } }</syntaxhighlight></div> Such programs have been produced with various cycle lengths: * [[Haskell (programming language)|Haskell]] β [[Python (programming language)|Python]] β [[Ruby (programming language)|Ruby]]<ref>{{cite web |url = http://blog.sigfpe.com/2008/02/third-order-quine-in-three-languages.html |title = A Third Order Quine in Three Languages |author = Dan Piponi |date = 5 February 2008 }}</ref> * [[Python (programming language)|Python]] β [[Bash (Unix shell)|Bash]] β [[Perl]]<ref>{{cite web |url = http://www.stratigery.com/source.html#Ouroboros |title = Ask and ye shall receive: Self-replicating program that goes through three generations, Python, Bash, Perl |author = Bruce Ediger |access-date = 2011-03-17 |archive-date = 2011-02-23 |archive-url = https://web.archive.org/web/20110223164033/http://www.stratigery.com/source.html#Ouroboros |url-status = dead }}</ref> * [[C (programming language)|C]] β [[Haskell (programming language)|Haskell]] β [[Python (programming language)|Python]] β [[Perl]]<ref>{{cite web |url = http://hpaste.org/43501/multiquine |title = multiquine |author = b.m. |date = 1 February 2011 |archive-url = https://archive.today/20130415050710/http://hpaste.org/43501/multiquine |archive-date = 2013-04-15 |url-status = dead }}</ref> * [[Haskell (programming language)|Haskell]] β [[Perl]] β [[Python (programming language)|Python]] β [[Ruby (programming language)|Ruby]] β [[C (programming language)|C]] β [[Java (programming language)|Java]]<ref>{{cite web |url = http://blog.sigfpe.com/2011/01/quine-central.html |title = Quine Central |author = Dan Piponi |date = 30 January 2011 }}</ref> * [[Ruby (programming language)|Ruby]] β [[Java (programming language)|Java]] β [[C Sharp (programming language)|C#]] β [[Python (programming language)|Python]]<ref>{{cite web |url = http://ruslan.ibragimov.by/20-04-2013.quine-ruby-java-c-python |title = Quine Ruby -> Java -> C# -> Python |author = Ruslan Ibragimov |date = 20 April 2013 |language = ru |access-date = 20 April 2013 |archive-date = 4 March 2016 |archive-url = https://web.archive.org/web/20160304040341/http://ruslan.ibragimov.by/20-04-2013.quine-ruby-java-c-python |url-status = dead }}</ref> * [[C (programming language)|C]] β [[C++]] β [[Ruby (programming language)|Ruby]] β [[Python (programming language)|Python]] β [[PHP]] β [[Perl]]<ref>{{cite web |url = http://golf.shinh.org/reveal.rb?Quine/shinh+%28C+C%2B%2B+Ruby+Python+PHP+Perl%29_1194650418&rb |title = Quine by shinh (C C++ Ruby Python PHP Perl) |author = Shinichiro Hamaji |date = 10 November 2007 }} (this one is also a [[Polyglot (computing)|polyglot]])</ref> * [[Ruby (programming language)|Ruby]] β [[Python (programming language)|Python]] β [[Perl]] β [[Lua (programming language)|Lua]] β [[OCaml]] β [[Haskell (programming language)|Haskell]] β [[C (programming language)|C]] β [[Java (programming language)|Java]] β [[Brainfuck]] β [[Whitespace (programming language)|Whitespace]] β [[Unlambda]]<ref>{{cite web |url = http://asiajin.com/blog/2009/09/22/uroboros-programming-with-11-programming-languages/ |title = Uroboros Programming With 11 Programming Languages |author = Ku-ma-me |date = 22 September 2009 |access-date = 17 March 2011 |archive-date = 29 August 2011 |archive-url = https://web.archive.org/web/20110829204605/http://asiajin.com/blog/2009/09/22/uroboros-programming-with-11-programming-languages/ |url-status = dead }}</ref> * [[Ruby (programming language)|Ruby]] β [[Scala (programming language)|Scala]] β [[Scheme (programming language)|Scheme]] β [[Scilab]] β [[Bash (Unix shell)|Shell (bash)]] β [[S (programming language)|S-Lang]] β [[Smalltalk]] β [[Squirrel (programming language)|Squirrel3]] β [[Standard ML]] β ... β [[Rexx]] (128 (and formerly 50) programming languages)<ref>{{cite web |url = https://github.com/mame/quine-relay |title = Quine Relay - An uroboros program with 100+ programming languages |author = Yusuke Endoh |website = [[GitHub]] |date = 2 November 2021 }}</ref> * Web application β [[C (programming language)|C]] (web application source code consists of [[HTML]], [[JavaScript]], and [[CSS]])<ref>{{cite web |url = http://michaelwehar.com/quines/c_prints_javascript.html |title = C Prints JavaScript |author = Michael Wehar |date = 10 November 2019 |language = en }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)