В качестве развлечения воскресным утром я хотел реализовать Quines на разных языках программирования.

По данным Википедии,

A quine is a computer program which takes no input and produces a copy of
its own source code as its only output. The standard terms for these
programs in the computability theory and computer science literature are
"self-replicating programs", "self-reproducing programs",
and "self-copying programs".

C

#include <stdio.h>
int main() { char *s="#include <stdio.h>%cint main() { char *s=%c%s%c; printf(s,10,34,s,34); }"; printf(s,10,34,s,34); }

Ява

public class MyClass {
public static void main(String args[]) {
String s = "public class MyClass {%cpublic static void main(String args[]) {%cString s = %c%s%c;%cSystem.out.println(String.format(s,10,10,34,s,34,10,10,10));%c}%c}";
System.out.println(String.format(s,10,10,34,s,34,10,10,10));
}
}

Питон

s = 's = {0!r}; print(s.format(s))'; print(s.format(s))

Голанг

package main
import "fmt"
func main() {
s := "package main%cimport %cfmt%c%cfunc main() {%cs := %c%s%c%cfmt.Printf(s,10,34,34,10,10,34,s,34,10,10)%c}"
fmt.Printf(s,10,34,34,10,10,34,s,34,10,10)
}

JavaScript

let s = "let s = %s%s%s; console.log(s,String.fromCharCode(34),s,String.fromCharCode(34))"; console.log(s,String.fromCharCode(34),s,String.fromCharCode(34))

Хаскель

import Text.Printf
main = do
  let s = "import Text.Printf%cmain = do%c  let s = %c%s%c%c  printf s (toEnum 10 :: Char) (toEnum 10 :: Char) (toEnum 34 :: Char) s (toEnum 34 :: Char) (toEnum 10 :: Char)"
  printf s (toEnum 10 :: Char) (toEnum 10 :: Char) (toEnum 34 :: Char) s (toEnum 34 :: Char) (toEnum 10 :: Char)

Ржавчина

от: https://www.reddit.com/r/rust/comments/iocgex/i_made_a_rust_quine/

fn main() {
    macro_rules! script {() => {"fn main() {{\n\tmacro_rules! script {{() => {{{:?}}}}}\n\tprintln!(script!(), script!());\n}}"}}
    println!(script!(), script!());
}

Кложур

(let [s "(let [s %c%s%c] (printf s (char 34) s (char 34)))"] (printf s (char 34) s (char 34)))

Эликсир

q=<<"q=~p;:io.format q,[q]">>;:io.format q,[q]

Четвертый

SOURCE TYPE