This language bar is your friend. Select your favorite languages!

Idiom #182 Quine program

Output the source of the program.

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 = `
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);}
! See original attribution URL
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])
public class Quine
{
  public static void main(String[] args)
  {
    char q = 34;      // Quotation mark character
    String[] l = {    // Array of source code
    "public class Quine",
    "{",
    "  public static void main(String[] args)",
    "  {",
    "    char q = 34;      // Quotation mark character",
    "    String[] l = {    // Array of source code",
    "    ",
    "    };",
    "    for(int i = 0; i < 6; i++)           // Print opening code",
    "        System.out.println(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() {
    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, "\""))
}

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

a