Logo

Programming-Idioms

Output the source of the current program. A quine is a computer program that takes no input and produces a copy of its own source code as its only output.

Reading the source file from disk is cheating.
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
int main(){char*s="int main(){char*s=%c%s%c;printf(s,34,s,34);return 0;}";printf(s,34,s,34);return 0;}
main(p){printf(p="main(p){printf(p=%c%s%1$c,34,p);}",34,p);}
public class Quine{public static void Main(){var s="public class Quine{{public static void Main(){{var s={0}{1}{0};System.Console.Write(s,(char)34,s);}}}}";System.Console.Write(s,(char)34,s);}}
q=<<"q=~p;:io.format q,[q]">>;:io.format q,[q]
! See original attribution URL
package main

import "fmt"

func main() {
	fmt.Printf("%s%c%s%c\n", s, 0x60, s, 0x60)
}

var s = `package main

import "fmt"

func main() {
	fmt.Printf("%s%c%s%c\n", s, 0x60, s, 0x60)
}

var s = `
main = putStr s >> print s where s = "main = putStr s >> print s where s = "
c=console.log
q=decodeURIComponent('%22')
l=[
"c=console.log",
"q=decodeURIComponent('%22')",
"l=[",
"]",
"for(i=0;i<3;i++)c(l[i])",
"for(i=0;i<7;i++)c(q+l[i]+q+',')",
"for(i=3;i<7;i++)c(l[i])",
]
for(i=0;i<3;i++)c(l[i])
for(i=0;i<7;i++)c(q+l[i]+q+',')
for(i=3;i<7;i++)c(l[i])
x = [["x = [" .. "[" .. x .. "]" .. "]\nprint(" .. x)]]
print("x = [" .. "[" .. x .. "]" .. "]\nprint(" .. x)
<?php $s='<?php $s=%c%s%c;printf($s,39,$s,39);';printf($s,39,$s,39);
program Quine(Output);const A='program Quine(Output);const A=';B='begin writeln(A,char(39),A,char(39),char(59),char(66),char(61),char(39),B,char(39),char(59),B)end.';begin writeln(A,char(39),A,char(39),char(59),char(66),char(61),char(39),B,char(39),char(59),B)end.
$_=q(print"\$_=q($_);eval;");eval;
s = 's = %r\nprint(s%%s)'
print(s%s)
eval s="print 'eval s=';p s"
fn main(){print!("{},{0:?})}}","fn main(){print!(\"{},{0:?})}}\"")}
fn main() {
    let x = "fn main() {\n    let x = ";
    let y = "print!(\"{}{:?};\n    let y = {:?};\n    {}\", x, x, y, y)\n}\n";
    print!("{}{:?};
    let y = {:?};
    {}", x, x, y, y)
}
object Quine extends App {
  val s = 
    """object Quine extends App {
      |  val s = 
      |    ""%2$s%1$s%2$s""
      |  print(s.stripMargin.format(s, "\""))
      |}"""
  print(s.stripMargin.format(s, "\""))
}