
Quine - lelf
https://rosettacode.org/wiki/Quine
======
st_goliath
On of my favorites in this kind of contests (what they funnily enough have an
entry for) is HQ9+.

Since it doesn't seem to have a regular English wiki article: It is an
esotieric language that is not turing complete but can do pretty much anything
that people usually do with esoteric languages. It has 4 opcodes:

H prints "Hello World!".

Q prints the source text of the input program (quine).

9 prints 99 bottles of beer.

\+ increments the accumulator.

~~~
st_goliath
Since a few people have posted links to language wikis, I clarify: when I said
"wiki article" I meant on Wikipedia.

There are articles on Wikipedia in a hand full of languages about HQ9+, but no
_regular_ English one (there is one in simplified English tough). I'm
surprised there even is a German one, usually people on the German Wikipedia
are quite trigger happy with deletion requests and speedy deletions.

------
juliangamble
You can write a minikanren program that will _generate_ quines.

> We will teach attendees how to use the relational (logic) language
> miniKanren to write several relational interpreters and reducers capable of
> automatically synthesizing recursive, symbolic programs, including quines
> (programs that evaluate to themselves) and fixpoint combinators (such as the
> famous Y-combinator). [https://www.thestrangeloop.com/2014/program-
> synthesis-using-...](https://www.thestrangeloop.com/2014/program-synthesis-
> using-minikanren.html)

\- miniKanren, live and untagged: quine generation via relational interpreters
(programming pearl)
([http://webyrd.net/quines/quines.pdf](http://webyrd.net/quines/quines.pdf))
by William E. Byrd, Eric Holk, and Daniel P. Friedman

------
cableclasper
A very useful application of quines:
[https://tiddlywiki.com/](https://tiddlywiki.com/)

Learned about it first from Joe Armstrong:
[https://joearms.github.io/#](https://joearms.github.io/#)

~~~
sirsuki
My homepage is a Quine: [https://tritarget.org/](https://tritarget.org/)

It is created using TiddlyWiki

------
azhenley
The Racket one is my favorite so far:

((λ (x) `(,x ',x)) '(λ (x) `(,x ',x)))

~~~
AlchemistCamp
Wow. I've only really looked at this in C and OO languages. That Racket
example distills the quine to its essence in a way I've never seen before. I
have to agree with you.

~~~
OskarS
It's arguably the most famous Quine of all, so famous that it has a pompous
name! It's called the Omega combinator in lambda calculus, and is a stepping
stone to the more famous Y combinator. If you think it's cool, the Y
combinator will blow your mind :)

~~~
AlchemistCamp
Already explored that one :D

------
brian_cloutier
Quines are fun! My favorite generalization is the quine relay: "This is a Ruby
program that generates Rust program that generates Scala program that
generates ...(through 128 languages in total)... REXX program that generates
the original Ruby code again." [https://github.com/mame/quine-
relay](https://github.com/mame/quine-relay)

The same author also has a radiation-hardened quine, which still emits the
original quine even if you delete any(!) one character before running it:
[https://github.com/mame/radiation-hardened-
quine](https://github.com/mame/radiation-hardened-quine)

But coming back to traditional quines; the most common solution is of the
form:

> The following string followed by itself in quotes: "The following string
> followed by itself in quotes: "

This is by no means the only possible solution: If you view the
compiler/interpreter as a function then a quine is the fixpoint of that
function.

So, if your "compiler" is `cat`, the shell identity function, then any string
is a quine! A fork bomb is also a kind of quine. The quine there is not the
code itself, but a process running the code. That process is "interpreted" by
the kernel, which dutifully creates an exact copy of the fork-bomb process.

I've never sat down and tried it, but one day I want to write a quine of the
form: "Initialize a PRNG with this seed and print the first n bytes". Probably
there's a language which lets you get the required code small enough that you
could brute-force the correct seed.

~~~
andrewflnr
One of my favorite (pseudo?-) quines is the shell script

    
    
      #!/usr/bin/cat

~~~
earenndil
That's a cat-script, not a shell-script.

~~~
andrewflnr
...fair enough. What's the general term for a shebang-ified text executable?

------
sammorrowdrums
They had a Quine programme featured in one of the Advent of Code problems
(that ran on the VM you built over the course of a few), I really enjoy the
links and extra stuff they include in AoC!

------
sirsuki
TiddlyWiki is still one of the best useful Quines out there!!!
[https://tiddlywiki.com/#Quine](https://tiddlywiki.com/#Quine)

------
core-questions
quine "quine"

