mame/quine-clique

51 quines in 51 languages, every one able to print every other

40

stars

2

commits

Makefile

primary language

Sep 1, 2026

updated

README

Quine Clique

qc.rb is a quine written in Ruby: a program that prints itself. Ask it for Python, and it prints a Python quine instead. Or a JavaScript quine. Or a Rust quine. Or a C quine. Or any of 50 languages in all.

Every one of those quines can do the same: all of them can generate each other. A clique of quines.

Quine Clique

▶ Video explanation (9 min)

Quine Clique 101

Ruby Quine

Here is qc.rb:

The text of qc.rb

This is a Ruby program. It is a quine. Run it, and it prints itself.

$ ruby qc.rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Ruby → Python

Run qc.rb with the argument py, and it prints a quine written in Python.

$ ruby qc.rb py > qc.py

Let's run it.

$ python3 qc.py > out.bin
$ diff -s qc.py out.bin
Files qc.py and out.bin are identical

Python → Ruby

Now, run qc.py with the argument rb. It prints qc.rb.

$ python3 qc.py rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

That is, qc.rb and qc.py are each a quine, and they print each other depending on the argument. This is called a multiquine.

qc.rb and qc.py printing each other

Ruby ↔ JavaScript

Python is not the only thing qc.rb can print. With the argument js, it prints a quine written in JavaScript.

$ ruby qc.rb js > qc.js
$ node qc.js > out.bin
$ diff -s qc.js out.bin
Files qc.js and out.bin are identical

Of course, qc.js can print qc.rb too.

$ node qc.js rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Python ↔ JavaScript

And Python and JavaScript can print each other as well.

$ python3 qc.py js > out.bin
$ diff -s qc.js out.bin
Files qc.js and out.bin are identical

$ node qc.js py > out.bin
$ diff -s qc.py out.bin
Files qc.py and out.bin are identical

That is, qc.rb, qc.py, and qc.js are each a quine, and they print each other depending on the argument.

qc.rb, qc.py, and qc.js printing each other

50 + 1 languages

In the same way, it supports 50 languages in total. Including Ruby itself, that makes 51. The picture at the top is this very graph: every arrow is a pair of programs that print each other.

Notably, it supports 5 esoteric languages: brainfuck, Befunge, Whitespace, Piet, and Unlambda. They do not support command-line arguments, so give the language name on standard input.

$ ruby qc.rb bf > qc.bf

# qc.bf is a quine
$ echo | vendor/bin/bf qc.bf > out.bin
$ diff -s qc.bf out.bin
Files qc.bf and out.bin are identical

# qc.bf can print qc.rb
$ echo rb | vendor/bin/bf qc.bf > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Languages

This program is tested with the following Ubuntu packages.

#languageubuntu packageversion
1Rubyruby1:3.3build1
2AWKgawk1:5.3.2-1ubuntu1.1
3Bashbash5.3-2ubuntu1
4BefungeN/A-
5brainfuckN/A-
6Cgcc4:15.2.0-5ubuntu1
7C#mono-devel6.14.1+ds2-2
8C++g++4:15.2.0-5ubuntu1
9Clojureclojure1.12.0-1build2
10CoffeeScriptcoffeescript2.7.0+dfsg1-4
11Common Lispclisp1:2.49.20250504.gitf662209-2
12Crystalcrystal1.18.2+dfsg-1
13Dgdc4:15.2.0-5ubuntu1
14Elixirelixir1.18.3.dfsg-1build1
15Erlangerlang1:27.3.4.6+dfsg-1
16F#dotnet-sdk-10.010.0.111-0ubuntu1~26.04.1
17Forthgforth0.7.3+dfsg-9build4.1
18Fortrangfortran4:15.2.0-5ubuntu1
19Gogolang2:1.26~1
20Groovygroovy2.4.21-10build1
21Haskellghc9.10.3-4
22Haxehaxe1:4.3.7-1.1
23Javaopenjdk-25-jdk25.0.4+7-1~26.04
24JavaScriptnodejs22.22.1+dfsg+~cs22.19.15-1ubuntu1
25Kotlinkotlin1.3.31+ds1-3ubuntu1
26Lualua5.35.3.6-3
27Nimnim2.2.4-2
28Objective-Cgobjc4:15.2.0-5ubuntu1
29OCamlocaml5.4.0-3ubuntu1
30Octaveoctave11.1.0-3
31Pascalfp-compiler3.2.2+dfsg-49
32Perlperl5.40.1-7ubuntu0.1
33PHPphp-cli2:8.5+99ubuntu1
34PietN/A-
35Pikepike8.08.0.1956-4
36PostScriptghostscript10.06.0~dfsg-3ubuntu1
37Prologswi-prolog9.2.9+dfsg-1.1build1
38Pythonpython33.14.3-0ubuntu2
39Rr-base4.5.2-1ubuntu2
40Racketracket8.18+dfsg1-1ubuntu1
41Rustrustc1.93.1ubuntu1
42Scalascala2.11.12-6build1
43Schemeguile-3.03.0.11-2
44Standard MLmlton20241230+git20251029+dfsg-5
45Swiftswiftlang6.1.3-4build1
46Tcltcl8.6.16build1
47TypeScriptnode-typescript5.2.2-2
48UnlambdaN/A-
49Valavalac0.56.18-7
50WhitespaceN/A-
51Zigzig0.14.1~us1-0ubuntu4

The languages marked N/A are not available in Ubuntu. This repository contains their interpreters in vendor/.

Usage

  1. If you are using Ubuntu 26.04, you can install the dependencies with:
$ sudo apt install bash clisp clojure coffeescript crystal \
      dotnet-sdk-10.0 elixir erlang fp-compiler g++ gawk gcc gdc gforth \
      gfortran ghc ghostscript gobjc golang groovy guile-3.0 haxe kotlin \
      libgif-dev libgmp-dev lua5.3 make mlton mono-devel nim node-typescript \
      nodejs ocaml octave openjdk-25-jdk perl php-cli pike8.0 python3 r-base \
      racket ruby rustc scala swi-prolog swiftlang tcl valac zig
  1. Then, build the bundled interpreters:
$ make -C vendor
  1. Then, run make members. This generates the whole clique: qc.py, qc.js, qc.rs, ...
$ make members
$ ls qc.*
qc.awk qc.bash qc.bef qc.bf qc.c qc.clj qc.coffee qc.cpp qc.cr qc.cs
qc.d qc.erl qc.exs qc.f90 qc.fs qc.fsx qc.go qc.groovy qc.hs qc.hx
qc.java qc.js qc.kt qc.lisp qc.lua qc.m qc.ml qc.nim qc.octave qc.pas
qc.php qc.piet.gif qc.pike qc.pl qc.prolog qc.ps qc.py qc.r qc.rb
qc.rkt qc.rs qc.scala qc.scm qc.sml qc.swift qc.tcl qc.ts qc.unl
qc.vala qc.ws qc.zig
  1. To verify that every language can print every other, run make test-all. It takes hours.
$ make test-all

All 51 x 51 = 2,601 combinations are checked by GitHub Actions on every push.

Alternatively, build the Docker image and run the tests in a container:

$ docker build -t quine-clique .
$ docker run --rm quine-clique

FAQ

Why?

Why not?

How?

See docs/internal.md, or watch the video.

  • Quine Relay (2013). A quine that returns to itself by way of 128 languages. A one-way chain, not a multiquine.
  • Quine Chameleon (2015). A 25-language multiquine. It is restricted to languages whose string literals support C-style escapes (\" and \\).
  • Multiquine with ELVM (2016, Japanese). A multiquine prototype based on ELVM, a compilation infrastructure for esolangs. ELVM is not multiquine-specific, and brainfuck could not be run in realistic time there.

License

The MIT License (MIT)

Copyright (c) 2026 Yusuke Endoh (@mametter), @hirekoke

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors

mame

2 commits

mame/quine-clique

51 quines in 51 languages, every one able to print every other

40

stars

2

commits

Makefile

primary language

Sep 1, 2026

updated

README

Quine Clique

qc.rb is a quine written in Ruby: a program that prints itself. Ask it for Python, and it prints a Python quine instead. Or a JavaScript quine. Or a Rust quine. Or a C quine. Or any of 50 languages in all.

Every one of those quines can do the same: all of them can generate each other. A clique of quines.

Quine Clique

▶ Video explanation (9 min)

Quine Clique 101

Ruby Quine

Here is qc.rb:

The text of qc.rb

This is a Ruby program. It is a quine. Run it, and it prints itself.

$ ruby qc.rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Ruby → Python

Run qc.rb with the argument py, and it prints a quine written in Python.

$ ruby qc.rb py > qc.py

Let's run it.

$ python3 qc.py > out.bin
$ diff -s qc.py out.bin
Files qc.py and out.bin are identical

Python → Ruby

Now, run qc.py with the argument rb. It prints qc.rb.

$ python3 qc.py rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

That is, qc.rb and qc.py are each a quine, and they print each other depending on the argument. This is called a multiquine.

qc.rb and qc.py printing each other

Ruby ↔ JavaScript

Python is not the only thing qc.rb can print. With the argument js, it prints a quine written in JavaScript.

$ ruby qc.rb js > qc.js
$ node qc.js > out.bin
$ diff -s qc.js out.bin
Files qc.js and out.bin are identical

Of course, qc.js can print qc.rb too.

$ node qc.js rb > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Python ↔ JavaScript

And Python and JavaScript can print each other as well.

$ python3 qc.py js > out.bin
$ diff -s qc.js out.bin
Files qc.js and out.bin are identical

$ node qc.js py > out.bin
$ diff -s qc.py out.bin
Files qc.py and out.bin are identical

That is, qc.rb, qc.py, and qc.js are each a quine, and they print each other depending on the argument.

qc.rb, qc.py, and qc.js printing each other

50 + 1 languages

In the same way, it supports 50 languages in total. Including Ruby itself, that makes 51. The picture at the top is this very graph: every arrow is a pair of programs that print each other.

Notably, it supports 5 esoteric languages: brainfuck, Befunge, Whitespace, Piet, and Unlambda. They do not support command-line arguments, so give the language name on standard input.

$ ruby qc.rb bf > qc.bf

# qc.bf is a quine
$ echo | vendor/bin/bf qc.bf > out.bin
$ diff -s qc.bf out.bin
Files qc.bf and out.bin are identical

# qc.bf can print qc.rb
$ echo rb | vendor/bin/bf qc.bf > out.bin
$ diff -s qc.rb out.bin
Files qc.rb and out.bin are identical

Languages

This program is tested with the following Ubuntu packages.

#languageubuntu packageversion
1Rubyruby1:3.3build1
2AWKgawk1:5.3.2-1ubuntu1.1
3Bashbash5.3-2ubuntu1
4BefungeN/A-
5brainfuckN/A-
6Cgcc4:15.2.0-5ubuntu1
7C#mono-devel6.14.1+ds2-2
8C++g++4:15.2.0-5ubuntu1
9Clojureclojure1.12.0-1build2
10CoffeeScriptcoffeescript2.7.0+dfsg1-4
11Common Lispclisp1:2.49.20250504.gitf662209-2
12Crystalcrystal1.18.2+dfsg-1
13Dgdc4:15.2.0-5ubuntu1
14Elixirelixir1.18.3.dfsg-1build1
15Erlangerlang1:27.3.4.6+dfsg-1
16F#dotnet-sdk-10.010.0.111-0ubuntu1~26.04.1
17Forthgforth0.7.3+dfsg-9build4.1
18Fortrangfortran4:15.2.0-5ubuntu1
19Gogolang2:1.26~1
20Groovygroovy2.4.21-10build1
21Haskellghc9.10.3-4
22Haxehaxe1:4.3.7-1.1
23Javaopenjdk-25-jdk25.0.4+7-1~26.04
24JavaScriptnodejs22.22.1+dfsg+~cs22.19.15-1ubuntu1
25Kotlinkotlin1.3.31+ds1-3ubuntu1
26Lualua5.35.3.6-3
27Nimnim2.2.4-2
28Objective-Cgobjc4:15.2.0-5ubuntu1
29OCamlocaml5.4.0-3ubuntu1
30Octaveoctave11.1.0-3
31Pascalfp-compiler3.2.2+dfsg-49
32Perlperl5.40.1-7ubuntu0.1
33PHPphp-cli2:8.5+99ubuntu1
34PietN/A-
35Pikepike8.08.0.1956-4
36PostScriptghostscript10.06.0~dfsg-3ubuntu1
37Prologswi-prolog9.2.9+dfsg-1.1build1
38Pythonpython33.14.3-0ubuntu2
39Rr-base4.5.2-1ubuntu2
40Racketracket8.18+dfsg1-1ubuntu1
41Rustrustc1.93.1ubuntu1
42Scalascala2.11.12-6build1
43Schemeguile-3.03.0.11-2
44Standard MLmlton20241230+git20251029+dfsg-5
45Swiftswiftlang6.1.3-4build1
46Tcltcl8.6.16build1
47TypeScriptnode-typescript5.2.2-2
48UnlambdaN/A-
49Valavalac0.56.18-7
50WhitespaceN/A-
51Zigzig0.14.1~us1-0ubuntu4

The languages marked N/A are not available in Ubuntu. This repository contains their interpreters in vendor/.

Usage

  1. If you are using Ubuntu 26.04, you can install the dependencies with:
$ sudo apt install bash clisp clojure coffeescript crystal \
      dotnet-sdk-10.0 elixir erlang fp-compiler g++ gawk gcc gdc gforth \
      gfortran ghc ghostscript gobjc golang groovy guile-3.0 haxe kotlin \
      libgif-dev libgmp-dev lua5.3 make mlton mono-devel nim node-typescript \
      nodejs ocaml octave openjdk-25-jdk perl php-cli pike8.0 python3 r-base \
      racket ruby rustc scala swi-prolog swiftlang tcl valac zig
  1. Then, build the bundled interpreters:
$ make -C vendor
  1. Then, run make members. This generates the whole clique: qc.py, qc.js, qc.rs, ...
$ make members
$ ls qc.*
qc.awk qc.bash qc.bef qc.bf qc.c qc.clj qc.coffee qc.cpp qc.cr qc.cs
qc.d qc.erl qc.exs qc.f90 qc.fs qc.fsx qc.go qc.groovy qc.hs qc.hx
qc.java qc.js qc.kt qc.lisp qc.lua qc.m qc.ml qc.nim qc.octave qc.pas
qc.php qc.piet.gif qc.pike qc.pl qc.prolog qc.ps qc.py qc.r qc.rb
qc.rkt qc.rs qc.scala qc.scm qc.sml qc.swift qc.tcl qc.ts qc.unl
qc.vala qc.ws qc.zig
  1. To verify that every language can print every other, run make test-all. It takes hours.
$ make test-all

All 51 x 51 = 2,601 combinations are checked by GitHub Actions on every push.

Alternatively, build the Docker image and run the tests in a container:

$ docker build -t quine-clique .
$ docker run --rm quine-clique

FAQ

Why?

Why not?

How?

See docs/internal.md, or watch the video.

  • Quine Relay (2013). A quine that returns to itself by way of 128 languages. A one-way chain, not a multiquine.
  • Quine Chameleon (2015). A 25-language multiquine. It is restricted to languages whose string literals support C-style escapes (\" and \\).
  • Multiquine with ELVM (2016, Japanese). A multiquine prototype based on ELVM, a compilation infrastructure for esolangs. ELVM is not multiquine-specific, and brainfuck could not be run in realistic time there.

License

The MIT License (MIT)

Copyright (c) 2026 Yusuke Endoh (@mametter), @hirekoke

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contributors

mame

2 commits

Languages

Makefile

56.9%

Ruby

36.2%