# Golf you a quine for great good!

Using your language of choice, golf a quine.

A quine is a non-empty computer program which takes no input and produces a copy of its own source code as its only output.

No cheating -- that means that you can't just read the source file and print it. Also, in many languages, an empty file is also a quine: that isn't considered a legit quine either.

No error quines -- there is already a separate challenge for error quines.

Points for:

• Smallest code (in bytes)
• Most obfuscated/obscure solution
• Using esoteric/obscure languages
• Successfully using languages that are difficult to golf in

The following Stack Snippet can be used to get a quick view of the current score in each language, and thus to know which languages have existing answers and what sort of target you have to beat:

var QUESTION_ID=69;
var OVERRIDE_USER=98;

getAnswers();var SCORE_REG=(function(){var headerTag=String.raw h\d
var score=String.raw \-?\d+\.?\d*
var normalText=String.raw [^\n<>]*
var strikethrough=String.raw <s>${normalText}</s>|<strike>${normalText}</strike>|<del>${normalText}</del> var noDigitText=String.raw [^\n\d<>]* var htmlTag=String.raw <[^\n<>]+> return new RegExp(String.raw <${headerTag}>+String.raw \s*([^\n,]*[^\s,]),.*?+String.raw (${score})+String.raw (?=+String.raw ${noDigitText}+String.raw (?:(?:${strikethrough}|${htmlTag})${noDigitText})*+String.raw </${headerTag}>+String.raw ))})();var OVERRIDE_REG=/^Override\s*header:\s*/i;function getAuthorName(a){return a.owner.display_name}
body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)
if(languages.hasOwnProperty(lang))
langs.push(languages[lang]);langs.sort(function(a,b){if(a.uniq>b.uniq)return 1;if(a.uniq<b.uniq)return-1;return 0});for(var i=0;i<langs.length;++i)
{var language=jQuery("#language-template").html();var lang=langs[i];language=language.replace("{{LANGUAGE}}",lang.lang).replace("{{NAME}}",lang.user).replace("{{SIZE}}",lang.size).replace("{{LINK}}",lang.link);language=jQuery(language);jQuery("#languages").append(language)}}
body{text-align:left!important}#answer-list{padding:10px;float:left}#language-list{padding:10px;float:left}table thead{font-weight:700}table td{padding:5px}
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/codegolf/primary.css?v=f52df912b654"> <div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td><a href="{{LINK}}">{{SIZE}}</a></td></tr></tbody> </table> 

• Do you not mean, "Golf you a quine for greater good!"? – Mateen Ulhaq May 3 '11 at 2:49
• @muntoo it's a play on "Learn you a Haskell for Great Good". – Rafe Kettler May 3 '11 at 2:52

# JavaScript, 58 54 bytes

I present to you the shortest non-source-reading quine in JavaScript:

console.log(a="console.log(a=%s,uneval(a))",uneval(a))


How have I not thought of this before? Screw that, how has nobody thought of this before? :P

Here's a version that works in all browsers at the cost of 9 bytes:

q='"';console.log(a="q='%s';console.log(a=%s,q,q+a+q)",q,q+a+q)

• If this works in the browser, you can make console.log be alert. – Conor O'Brien Sep 7 '16 at 1:56
• @ConorO'Brien Nope. The %s in the string only works with console.log. – ETHproductions Sep 7 '16 at 2:00
• ahhh that's what that was. – Conor O'Brien Sep 7 '16 at 11:02
• Lolp I was trying to do that a while ago, I couldn't figure out string formatting – Oliver Ni Oct 23 '16 at 5:26

## C++, 117 bytes

#include<cstdio>
#define Q(S)char*q=#S;S
Q(int main(){printf("#include<cstdio>\n#define Q(S)char*q=#S;S\nQ(%s)",q);})

• What compiler does this use? This does not appear to work on gcc. – Post Rock Garf Hunter Jan 13 '17 at 15:26
• It works on my gcc 4.9.2. – Ralph Tandetzky Jan 13 '17 at 15:38
• Ok. According to clang, this is not valid C++, since the return type of main() is missing. I fixed that now. – Ralph Tandetzky Jan 13 '17 at 15:40
• My version of gcc was 4.2.1 (I should update some time). Now that main has a return type it works. – Post Rock Garf Hunter Jan 13 '17 at 15:47

# Befunge-98 (cfunge), 8 characters

 'k<@,k␇


␇ represents a literal BEL character (ASCII 7, or Ctrl-G). (Note also that the program starts with a leading space.)

Note that the k command, which is heavily used here, is somewhat imprecisely defined, and this code is outright exploiting several edge cases at once, making this an example of corner-case code. As such, this is somewhat interpreter-dependent; it doesn't work on TIO, for example. cfunge is the Befunge-98 interpreter I normally use locally (and has been tested to be highly conformant with the specification), and it handles this code correctly. (Update: I've been talking to some Befunge experts about this quine, and the consensus is that it's exploiting a bug in cfunge, not behaviour that's defensible by the specification. Still a valid answer, though, because languages are defined by their implementation and this is the sort of corner case that has no right answers, only wrong answers.)

This program would also work in Unefunge-98 and Trefunge-98, but I'm not sure if any of the pre-existing interpreters for those handle k in the way we need, so it may be noncompeting in those languages.

## Verification

$xxd /tmp/quine.b98 00000000: 2027 6b3c 402c 6b07 'k<@,k.$ ./cfunge /tmp/quine.b98 | xxd
00000000: 2027 6b3c 402c 6b07                       'k<@,k.


## Explanation

### General principles

We know that in fungeoids, it's normally easiest to wrap a string around the code, so that the code is inside and outside the string literal at the same time. However, another trick for shortening quines is to use a string representation which doesn't need escaping, so that we don't need to spend bytes to represent the string delimiter itself. So I decided to see if these techniques could be combined.

Befunge-98 normally uses " as a string delimiter. However, you can also capture a single character using ', and you can make any command into a sort of lightweight loop (in a confusing and buggy way) using k. As such, k' functions as a sort of makeshift length-prefixed string literal. And of course, a length-prefixed string literal has no problems in escaping its own delimiter, as it doesn't have any sort of string terminator at all, meaning that the entire range of octets (in fact, the entire range of cell values) are available to exist within the string.

We can actually do even better; we no longer have to stop the string at its opening delimiter (we can stop it anywhere), so we can wrap it multiple times around the program to grab not only the k' itself, but also the length of the string (which is in this case written as a character code, thus the literal backspace). The program will continue execution just after the end of the string, i.e. just after the last character captured, which is exactly where we want it. (Bear in mind that Befunge strings are printed in reverse order to pushing them; the most common form, NUL-terminated strings, are called "0gnirts" by the community because of this, and length-prefixed strings follow the same principle. Thus if we want the length to end up at the start of the string, we have to push it last.)

As an extra bonus, this also means that we can wrap multiple times around the program with no penalty; all that matters is that the last character we see is the string length (which is at the end of the program). By an amazing stroke of luck, k' specifies length-prefixed string (sort-of; k is weird), and 'k (the same two characters in reverse order) pushes 107, which happens to loop round the program multiple times and end up in exactly the right place (this only had a 1 in 8 chance of working out). Because we have to reverse the program direction anyway (to read the string in the reverse of the natural reading order, meaning that it gets printed in the same order it appeared in the original program), we can use the same two characters for both pushing the length, and pushing the string itself, at no cost.

Of course, this now captures a risk of counting as a literal-only program, and thus not a proper quine under PPCG rules. Luckily, wrapping round from one end of the program to the other produces a literal space character, and spaces at the ends of the line (i.e. leading and trailing whitespace) aren't captured as part of a string. Thus, if we start the program with a space, we can encode that space (which isn't part of the string literal) via the implicit space that we get from wrapping the program (i.e. the leading space is encoded by the ' next to it, rather than by itself), just sneaking within the proper quine rules. The easiest way to see this is to delete the leading space from the program; you'll get the same output as the program with the leading space (thus effectively proving that it doesn't encode itself, because even if you remove it it still gets printed).

### Detailed description

 'k<@,k␇
'k       Push 107 to the stack
<      Set execution delta to leftwards
'k       Push the next 107 characters to the stack: "'␠␇k, … @<ck'␠␇"
,k   Pop a length from the stack, output that many characters
,    Output the top stack element
@     Exit the program


You can note that k has some odd ideas of where to start reading the string from (for the first k that runs), or where to leave the IP afterwards (for the second k that runs); this is just the way k happens to work (you think of k as taking an "argument", the command to run, but it doesn't actually move the IP to skip the "argument"; so if the command inside the loop doesn't affect the IP or the IP's movement, it'll end up being the next command that runs and the loop runs one more time). The literal BEL, ASCII 7, is interpreted by the second k as a loop counter, so the , inside the k will print the first 7 characters, then the , outside the k (which is the same character in the source) will print the 8th just before the program exits.

# Brachylog (2), 26 bytes, language postdates challenge

"ạ~bAh34∧A~ạj"ạ~bAh34∧A~ạj


Try it online!

A function that returns its own source code. (This can be made into a 28-byte full program by adding w after each occurrence of j.)

## Explanation

"ạ~bAh34∧A~ạj"ạ~bAh34∧A~ạj
"ạ~bAh34∧A~ạj"               String literal
ạ              Convert to list of character codes
~b            Prepend an element
h34          so that the first element is 34
A   ∧A        but work with the entire list
~ạ    Convert to string
j   Concatenate the string to itself


# Alice, 45 bytes

Credit to Martin Ender for the use of %, r, and y to obtain the characters "/\ without escaping.

/?.!eO%?.*y1?@~mtz!!4\
\"Y!Z1hrZRoY@*m*h%1Y{/


Try it online!

This program runs entirely in ordinal mode. Because of how ordinal mode programs need to be formatted, this is significantly longer than Martin Ender's cardinal mode quine.

In ordinal mode, the instruction pointer moves diagonally, and commands work on strings instead of integers. The diagonal movement is what makes this tricky: there is even a challenge specifically about formatting a program for ordinal mode. While it's possible to sidestep the entire issue by putting the same string on both lines, this approach ends up slightly longer at 52 bytes.

\".!e1%r.Ryh?*.Ooo1m@z1!{
\".!e1%r.Ryh?*.Ooo1m@z1!{/


Try it online!

## Explanation

This is a standard template for ordinal mode, with an additional mirror to allow the program to loop back to the beginning. Linearized, the code is as follows:

".!e1%r.RyY?*~*t%!Y4?Y!ZOh?Z*o1@@mmhz1!{


As with many Fungeoid quines, the " wraps around to itself and puts this entire program in a string literal. Since string mode treats mirrors as mirrors (instead of literals), the string that gets pushed is exactly the linearized code, excluding the ".

.!     Duplicate the string, and move the copy to tape
e1%    Split on "1", placing "@@mmhz" and "!{" on top of the stack.
The other two parts are irrelevant.
r      Expand !{ into the entire range from code point 33 to 123.
.R     Duplicate and reverse this range
y      Modify the string @@mmhz by changing every character in the range 33-123
with the corresponding character in the reversed range.
The result of this transformation is \\//4" .
This allows us to get these characters without escaping them.
Y?*~*  Split this string in half by unzipping, and put the halves on either
side of the original string.  The new string is \/"sourcecode\/4 .
t%     Extract the newly added 4 at the end, and use it to split on the single 4 in the code.


At this point, we have two strings corresponding to approximately half of the code. The top of the stack has the second half of the program and the right side mirrors, and corresponds to these output bytes:

 ? ! O ? * 1 @ m z ! \
Y Z h Z o @ m h 1 {/


The string below that has the first half of the program, along with the left side mirrors and quote:

/ . e % . y ? ~ t !
\" ! 1 r R Y * * % Y


Neither string currently contains the 4 that was used to split the string.

!      Move second half string to the tape.
Y      Unzip first half: the top of the stack now contains the characters
from the first half that will end up in the first row of the output.
4      Append the digit 4 to this string.
?Y     Copy second half back from tape and unzip: the top of the stack contains
characters from the second half that will end up in the second row
!      Move this onto the tape.
Z      Zip the two halves of the first row together.
O      Output this with a linefeed.
h      Temporarily remove the initial \ so the next zip will work right.
?Z     Copy the string back from the tape, and zip the second row together.
This Z isn't the exact inverse of Y since the second half is longer.
The resulting behavior is exactly what we want.
*o     Join with the previously removed \ and output.
1      Append 1 to the irrelevant string on the top of the stack.
@      Terminate.


The 52-byte quine works on exactly the same principle, except that it doesn't need the ordinal formatting section of the 45-byte quine.

# Taxi, 1144 1034 970 bytes

"is waiting at Writer's Depot.34 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 r 3 l 2 l 3 l 2 r.Pickup a passenger going to Charboil Grill.Go to Charboil Grill:e 1 l.Pickup a passenger going to KonKat's.Go to Writer's Depot:w 1 r.Pickup a passenger going to KonKat's.Go to KonKat's:n 3 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Post Office:s 1 l 2 r 1 l."is waiting at Writer's Depot.34 is waiting at Starchild Numerology.Go to Starchild Numerology:w 1 r 3 l 2 l 3 l 2 r.Pickup a passenger going to Charboil Grill.Go to Charboil Grill:e 1 l.Pickup a passenger going to KonKat's.Go to Writer's Depot:w 1 r.Pickup a passenger going to KonKat's.Go to KonKat's:n 3 r 2 r.Pickup a passenger going to Cyclone.Go to Cyclone:n 1 l 2 l.Pickup a passenger going to Post Office.Pickup a passenger going to Post Office.Go to Post Office:s 1 l 2 r 1 l.


Please ignore the output to stderr. Who needs a job if you can quine anyway?

Try it online!

# How does this work?

This quine starts with a string. If you replace the content of that string by <string>, the code looks like "<string>"<string>, which is "<string> twice. Because the string doesn't contain the double quote, we first get the double quote via its character code, concatenate it with the string, then copy the string and concatenate it with itself. Finally, we print the string.

under construction

# tinylisp, 88 bytes

The byte count includes a trailing newline.

((q (g (c (c (q q) g) (c (c (q q) g) ())))) (q (g (c (c (q q) g) (c (c (q q) g) ())))))


Try it online!

There are no strings in tinylisp, but a nontrivial quine is still possible because code is lists and lists are code. The above code is a list which, when evaluated, returns (and therefore prints) itself.

The idea is to pass the list (g (c (c (q q) g) (c (c (q q) g) ()))) to a function which will wrap it in a list, tack a q on the front, and then wrap two copies of that in a list. Which is exactly what the function (q (g (c (c (q q) g) (c (c (q q) g) ())))) does. In-depth explanation available on request, but I wanted to post this before turning in for the night.

# Operation Flashpoint scripting language,  22  15 bytes

q={"q={"+q+"}"}


Call with:

hint call q


Output:

Old version (22 bytes):

q={format["q={%1}",q]}


(:aSS):aSS


Try it online!

## JavaScript, 53 bytes

A quine without any uses of uneval or Function.prototype.toString.

Q="q=Q.link()[8];alert(Q=${q+Q+q};eval(Q))";eval(Q) Can avoid use of template strings for + 1 byte. Q="q=Q.link()[8];alert('Q='+q+Q+q+';eval(Q)')";eval(Q) ## JavaScript, 74 bytes Another approach avoiding uneval and Function.prototype.toString: console.log(a="console.log(a=%s%s%s,q=a.link()[8],a,q)",q=a.link()[8],a,q) # Pain-Flak, 2009 bytes ><))(())(())()(())(())()(())(())(())(())()()(())()(())(())()()()(())(())()(())(())()()(())(())(())()(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()(())(())(())()()(())()()(())(())(())()()(())(())(())()()()(())(())(())()()()(())(())()()(())()(())()()(())(())()()()(())(())(())(())(())(())()(())()()()(())()(())()()(())(())()()()(())(())(())()()()(())(())()()(())()(())(())()()(())()()(())(())(())()()(())(())(())(())(())(())()()()(())(())(())()()(())(())(())(())()()(())()()(())()()()(())(())()()(())()(())(())()()(())(())(())(())(())(())()()(())()()()(())(())()(())(())()()(())()(())()()(())()()()(())(())()()(())(())(())(())(())(())()()(())()()()(())()(())(())()(())()()(())(())()(())()()()()(())()(())(())(())(())(())(())(())(())()(())(())(())()()(())()(())(())(())(())(())()()()(())()(())(())()()(())(())(())()()(())()(())(())(())()()(())()(())()(())(())(())(())()()(())()(())()()()()(())()(())()(())()()()(())(())(())()(())(())()()(())(())(())()()(())()(())(())(())()()(())()(())()(())(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()()()(())(())()(())(())()()(())()(())()(())()()()(())()(())(())(())()(())()()()()(())()()(())(())()(())()(())(())(())(())()()(())(())(())()()()(())(())(())()()()(())(())()()(())()(())()()(())(())()()()(())(())(())()()()(())(())(())(())()(())(())(())(())()(())()()()()(())(())()()(())()(())()(())()(())(())()()()(())(())(())()(())(())()()(())()(())()()(())()()()(())(())()(())(())(())(())()()(())()()()()(())()(())()(())(())()()()(())(())(())()(())(())(())()()(())(())(())()()(())(())(())()()(())(())(())()(())(())()(())(())()(())(())()(())(())()(())()(())()(())()(())()(())()(())(())()()()(())()()((}><))))))()()()()((}{(}{(}{()((><))]}{[()(>})}{)((><)))}{])([()(((><{><})}{><(><{}{<())(}])([)>))}{)(>))))()()()()((}{())}{()}{(}{)((>))])}{([))}{()}{(}{)><((()}{()((<(<(()])(})()>}{<({[}{>})}{)(>}{<({<}{)}{>}}{{<}{(><(<({}{(}}{)}{><(><})>)(<({{><})}{><(><{}{{}}{{)))))()()()((}{)((}{)(><)}{(()()((  Try it online! (Trailing newline because the interpreter outputs a newline.) -176 bytes by improving the Brain-Flak quine Basically a straight port of my Brain-Flak quine. The only major difference is the >< at the beginning, which is required in order to keep the data section out of the output. >< switch to right stack; effectively does nothing since both stacks are empty ))((...))()()(( data, same format as the Brain-Flak quine }main loop{ same as the Brain-Flak quine, but with different constants }}{{ clear current stack; this does nothing )))))()()()((}{)((}{)(><)}{(()()(( push opening >< at beginning of code  Since this is Pain-Flak, the code also goes backward after it is finished going forward. As such, I had to ensure that this does not mess up the output. ))()())}{(><)(}{))(}{))()()()((((( push 70, 68, 5, 4 on right stack }}{{ clear right stack }pool niam{ do nothing because top of stack is zero ))()()((...))(( push constants on right stack in reverse order >< switch to left stack and implicitly output  • The only Pain-Flak solutions I've seen are ones directly translated from Brain-Flak... – Jo King Apr 10 '18 at 5:21 • I will give the bounty but kinda lame that it is just a port – Christopher Apr 25 '18 at 10:39 • @Christopher it is your fault that you made Pain-Flak so similar to Brain-Flak :P – ASCII-only Apr 30 '18 at 22:13 • @ascii painflak update is removing swap stack – Christopher Apr 30 '18 at 22:47 • @Christopher then it'll just be translated Mini-flak? – ASCII-only Apr 30 '18 at 23:09 # Reflections, 9228 bytes As the program has 8620 lines, I won't put it here completely. First line: \  Then, for each character in the last part (below), there are n newlines for ASCII character n, followed by: + #  After it, the last part is (the # is actually already covered by the previous section): # / \ /+\ /#_=0v\ >~ < /(1:1)#@/ ~ $$0/ 2) \3)(2:2)(3^ 0#+#@ \:(24):(4#_#_#_ / + \* (4\ \*(1(2 +/  Test it! Working on explanation. I had to fix a bug in the interpreter for this one. Does that count as adding a feature just for a challenge? • :| the URL encoding format is terrible – ASCII-only May 22 '18 at 0:57 # 2DFuck, 1352 1289 bytes !xv>>>>x>x>>>>>>x>x>x>x>>x>x>x>>x>x>>x>x>x>x>x>>x>x>>x>x>>x>x>x>x>x>>x>x>x>x>x>>x>x>x>x>>x>x>>x>x>x>>x>x>>x>>>x>>>>>>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>x>x>>>>>x>>>x>>>x>x>>x>x>x>x>x>>x>x>x>x>>>x>x>x>x>>x>x>x>x>x>x>>x>x>>>>>>>>>>x>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>>>>>x>>x>>>x>x>>x>>>x>>>>>>x>x>x>>>>>x>>>x>>>x>x>x>>x>x>>x>x>>x>x>x>x>>x>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>x>x>x>>x>x>>x>x>x>x>x>>x>x>>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>x>>x>x>>x>x>>x>>>x>x>>>>x>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>>x>x>>x>x>x>>x>>>x>x>>>>>x>>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>x>x>>x>x>x>>x>x>>x>x>>>x>x>>>>x>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>x>>x>x>x>x>x>x>>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>x>>x>x>x>x>x>>x>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>x>>>x>>>x>x>>x>x>>x>x>>x>x>x>x>x>>x>x>>>x>x>>>>x>>>x>>>>>>>>>>x>>>x>>>x>x>>x>x>x>x>x>>x>x>x>x>>>x>x>>>>x>>x>>>x>>>x>x>>x>x>x>x>>x>x>>x>x>x>>x>x>>>x>x>>>x>x>>>x>x>>>x>x>>>x>x>>>>>x>>>>x>x>>>>>>>>x>x>>>x>x>>>>>>>>>>x>x>>>>>x>>x>>>x>x>^x!..!.!....!.!.!....!....!...!.!..!.![<r!]![vr[!.!....!...]..!.....!.>^r!]![<r!]![vr[!..!.!.!...!.]r![>r[!..!.!....!.!]r![>r[>r[!.!.!.!...!.!.!]r![!.!.!.!..!.!..!]<]r![>r[!.!...!..!.!.]r![>r![!..!.....!.]r[>r![!..!....!..]r[>r![!.!.!.!....!.]r[>r[!.!....!...]r![!.!...!.!..!.]]]]]<]>]]>^r!]  Try it online! Shaved off 63 bytes with Huffman coding! New explanation in progress. # Z80Golf, 120 bytes 00000000: 21f5 76e5 2180 10e5 21cd 00e5 2180 7ce5 !.v.!...!...!.|. 00000010: 21cd 00e5 21e1 7de5 2106 14e5 2110 e8e5 !...!.}.!...!... 00000020: 2100 80e5 21e5 cde5 211b 3ee5 2100 80e5 !...!...!.>.!... 00000030: 211a cde5 2180 13e5 21cd 00e5 211b 1ae5 !...!...!...!... 00000040: 2180 1be5 21cd 00e5 213e 21e5 2106 14e5 !...!...!>!.!... 00000050: 0614 3e21 cd00 801b 1b1a cd00 8013 1acd ..>!............ 00000060: 0080 1b3e e5cd 0080 10e8 0614 e17d cd00 ...>.........}.. 00000070: 807c cd00 8010 f576 .|.....v  Try it online! Verification:  ./z80golf a.bin | xxd 00000000: 21f5 76e5 2180 10e5 21cd 00e5 2180 7ce5 !.v.!...!...!.|. 00000010: 21cd 00e5 21e1 7de5 2106 14e5 2110 e8e5 !...!.}.!...!... 00000020: 2100 80e5 21e5 cde5 211b 3ee5 2100 80e5 !...!...!.>.!... 00000030: 211a cde5 2180 13e5 21cd 00e5 211b 1ae5 !...!...!...!... 00000040: 2180 1be5 21cd 00e5 213e 21e5 2106 14e5 !...!...!>!.!... 00000050: 0614 3e21 cd00 801b 1b1a cd00 8013 1acd ..>!............ 00000060: 0080 1b3e e5cd 0080 10e8 0614 e17d cd00 ...>.........}.. 00000070: 807c cd00 8010 f576 .|.....v ./z80golf a.bin | diff -s a.bin - Files a.bin and - are identical  Looks like no one tried to make a proper quine in machine code yet, so here is one. Although the machine code is loaded to memory, it does NOT read any address occupied by the code. Instead, it uses the stack space to setup required data. ### Disassembly start: ld hl, 76f5 push hl ld hl, 1080 push hl ld hl, 00cd push hl ld hl, 7c80 push hl ld hl, 00cd push hl ld hl, 7de1 push hl ld hl, 1406 push hl ld hl, e810 push hl ld hl, 8000 push hl ld hl, cde5 push hl ld hl, 3e1b push hl ld hl, 8000 push hl ld hl, cd1a push hl ld hl, 1380 push hl ld hl, 00cd push hl ld hl, 1a1b push hl ld hl, 1b80 push hl ld hl, 00cd push hl ld hl, 213e push hl ld hl, 1406 push hl ld b, 20 loop1: ld a, 21 call 8000 dec de dec de ld a, (de) call 8000 inc de ld a, (de) call 8000 dec de ld a, e5 call 8000 djnz loop1 ld b, 20 loop2: pop hl ld a, l call 8000 ld a, h call 8000 djnz loop2 halt  At start, the stack pointer sp is zero, just like other registers. Pushing some values causes sp to decrease, so the values are stacked in the memory region ffxx. The combination ld hl, xxxx and push hl seems like the best option to dump predefined values into some memory space. It takes 4 bytes to store 2 bytes; any other option I could think of uses 3 or more bytes to store only one byte. The first loop prints the ld hl, xxxx (21 xx xx) and push hl (e5) instructions for the data, from the bottom of the stack (the address, represented by de, is decreased starting from 0000). ld b, xx and djnz label combined forms a fixed-times looping construct. It is only 4 bytes, which is optimal in Z80 (unless the loop count is already saved in another register). But there is an endianness problem here, so simply sweeping the memory addresses in decreasing order does not work. So I had to add a pair of dec de and inc de at the cost of 2 bytes (plus 4 bytes to push the 2 bytes into the stack). The second loop prints the main code by popping data from the stack. ### Possible improvement ideas Since the code is longer than 38 or 56 bytes, we can't use rst 38 in place of call 8000. Having call 8000 6 times in total, it's a great opportunity for golf. I considered placing call 8000; ret at address 38, but then I have to reduce the main code into 26 bytes or lower. I also thought of moving the code to the front by adding some jr, so that I can embed the call 8000; ret in the code part. But then I can't use the efficient "pop and print" loop. It prints the data in reverse order of pushing, so it can't be used to print the push part; the "print" overwrites the stack with the return address, so it can't be used to print the first part either. Finally, there is room for alternative encoding since some bytes frequently appear in the code. But Z80 itself is severely limited in arithmetic... # MathGolf, 9 bytes ÿ_'ÿ¬_'ÿ¬  Try it online! ### Explanation: ÿ_'ÿ¬_'ÿ¬ ÿ Start string of length 4 _'ÿ¬ Push "_'ÿ¬" _ Duplicate it 'ÿ Push the character "ÿ" ¬ Rotate stack so the "ÿ" is at the bottom Implicitly output "ÿ", "_'ÿ¬", "_'ÿ¬" join together  • ÿ'ÿ¬_'ÿ¬_ is another 9-byter. – maxb Jan 7 '19 at 11:56 # Whitespace, 406 bytes DISCLAIMER: This quine was not created by me, it is created by Smithers. Because this challenge was missing a Whitespace answer I decided to post his/her. If Smithers reads this and wants to post it himself/herself I will of course delete my answer. Sources: Smithers' website and his/her Whitespace quine source code (note: it's missing a trailing new-line). [S S S T S S T S T T T T T S T T T S S T T S S S T S T T S T T T T T T T S T S S S T S S T S S T S T T T T T S T S T S S S T T T S S T S T T S S S S T T T T T T S S T T T S T S T S S S T T T S S S S S S S T T T T T T T S T S S T S S S T S T T T T S S S S S T S T S S S T S T T S T S S S T S S T S S T T T S S S S S S S T T S T S S T T T T T S S S T T T T S S T T S T T S S T S T T T T S S S S T T S S T T T T S T S S T T S S T S S T T S S S S T T S S T T S S T S S T T S T S T S T T S S S T T S T S N _Push_67079405567184005086107571748115383207539763039497665210559156555730234138][S N S _Duplicate][N S T S N _Call_Label_PRINT_SPACE][N S T S N _Call_Label_PRINT_SPACE][S S S T S N _Push_2][S N T _Swap][N S T N _Call_Label_RECURSIVE_PRINTER][S S S T S T S N _Push_10][T N S S _Print_as_char][S N N _Drop][S S S T T N _Push_3][S N T _Swap][N S T N _Call_Label_RECURSIVE_PRINTER][N N N _Exit][N S S N _Create_Label_RECURSIVE_PRINTER][S N S _Duplicate][N T S T N _If_0_Jump_to_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S T S S T N _Copy_1][S T S S T N _Copy_1][S T S S T N _Copy_1][T S T S _integer_divide][N S T N _Call_Label_RECURSIVE_PRINTER][T S T T _Modulo][S N S _Duplicate][N T S T N _If_0_Jump_to_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S S S T S S S N _Push_8][T S S S _Add][T N S S _Print_as_character][N T N _Return][N S S T N _Create_Label_DISCARD_TOP(_AND_PRINT_SPACE)][S N N _Discard][N S S S N _Create_Label_PRINT_SPACE][S S S T S S S S S N _Push_32][T N S S _Print_as_character][N T N _Return]  Letters S (space), T (tab), and N (new-line) added as highlighting only. [..._some_action] added as explanation only. Try it online (with raw spaces, tabs and new-lines only). Whitespace is a stack-based language only using three characters: spaces, tabs and new-lines. In Whitespace the stack can only contain integers, and there are two options to print something to STDOUT: "Print as number" and "Print as character". In the case of "Print as character" it will print the character based on the unicode value at the top of the stack. Because whitespace uses spaces, tabs and new-lines, it means it'll have to print numbers 32, 9, and 10 respectively as characters to STDOUT for this quine. Smithers uses a pretty ingenieus piece of code with the magic number (s)he found. Pseudo-code: Push 67079405567184005086107571748115383207539763039497665210559156555730234138 Duplicate top Call function_PRINT_SPACE Call function_PRINT_SPACE Push 2 Swap top two Call function_RECURSIVE_PRINTER Push 10 Pop and print top as character Discard top Push 3 Swap top two Call function_RECURSIVE_PRINTER Exit program function_RECURSIVE_PRINTER: Duplicate top If 0: Call function_DISCARD_TOP(_AND_PRINT_SPACE) Make a copy of the 2nd top item of the stack Make a copy of the 2nd top item of the stack Make a copy of the 2nd top item of the stack Integer-divide top two Call function_RECURSIVE_PRINTER Modulo top two Duplicate top If 0: Call function_DISCARD_TOP(_AND_PRINT_SPACE) Push 8 Add top two Pop and print top as character Return function_DISCARD_TOP(_AND_PRINT_SPACE): Discard top function_PRINT_SPACE: Push 32 Pop and print top as character Return  It first uses a recursive-loop which keeps integer-dividing the initial integer by 2 until it's 0. Once it's 0, it goes back over these values and does modulo-2, printing either a space (if the modulo-2 resulted in 0) or a tab (by adding 8 to the modulo-2 result of 1). This first part is used to print the magic number itself, which only consists of spaces and tabs, because pushing a number in Whitespace is done as follows (and thus doesn't contain any new-lines except for the single trailing one): • S: Enable Stack Manipulation • S: Push a number • S/T: Positive/Negative respectively • Some S/T, followed by a trailing N: The number as binary, where S=0 and T=1 After it has printed the spaces and tabs required for pushing the magic number itself, it pushes a 3 and will use the same recursive function with the magic number, integer-dividing and using modulo 3 instead of 2. Which will print the spaces (if the modulo-3 resulted in 0), or tabs/new-lines (by adding 8 to the modulo-3 result). • You may be interested in my new Whitespace quine – Jo King Oct 8 '19 at 3:05 • @JoKing Very nice! Well done! :) – Kevin Cruijssen Oct 8 '19 at 7:31 # APL (Dyalog Unicode), 18 bytesSBCS @ngn's updated version of the classic APL quine, using a modern operator to save four bytes. 1⌽,⍨9⍴'''1⌽,⍨9⍴'''  Try APL! '''1⌽,⍨9⍴''' the characters '1⌽,⍨9⍴' 9⍴ cyclically reshape to shape 9; '1⌽,⍨9⍴'' ,⍨ concatenation selfie; '1⌽,⍨9⍴'''1⌽,⍨9⍴'' 1⌽ cyclically rotate one character to the left; 1⌽,⍨9⍴'''1⌽,⍨9⍴''' # Ruby, 27 bytes eval s="><<'eval s=';p s"  Try it online! ><<'...' is equivalent to print'...' (outputs the string without a newline). Note the newline at the end of the program. • Welcome to the site! Nice first answer :) – DJMcMayhem Jun 12 '17 at 17:07 • doesn't p print a newline? – Shelvacu Aug 11 '19 at 23:20 • @Shelvacu You're right; it should be 27 bytes. Interestingly, I went back and looked around, and I couldn't find any Ruby quines that included a newline in their source to match the output. Most seem to add an extra newline in their output like this one did. I also have a vague memory of coming across a 25-byte Ruby quine somewhere, I think in a demonstration of a new-at-the-time feature, but I haven't been able to find it again. – Nnnes Aug 12 '19 at 23:43 # Keg, 49 43 bytes \^\(\\\\\,\:\&\^\&\^\,$$\^\#^(\\,:&^&^,)^#  Try it online! (note the trailing newline...) -6 bytes thanks to Jo King reminding me that comments exist This is a horrible mess, and I'm sure it can be outgolfed easily by someone comfortable with Keg's stack, and/or once "/' stop erroring. The first two thirds simply push each character from the last third to the stack in order (such that the last character is on top), and then the last third: ^ Reverses the stack (such that the first character is on top), ( ) then does the following for each item CURRENTLY on the stack: \\, print a backslash, : duplicate the top of the stack, & pop it to the register, ^ flip the stack, & push the register, ^ flip the stack again, , and pop and print the top of the stack; ^ finally reversing what's left on the stack #\n and commenting out the trailing newline, so the stack is then implicitly printed bottom first, with a trailing newline.  Essentially, it prints the first two thirds while copying itself onto the bottom of the stack, then flips the copy to be implicitly printed. • Thanks, fixed now... wait no – Unrelated String Oct 1 '19 at 5:15 • Now it's fixed – Unrelated String Oct 1 '19 at 5:44 # Keg, 21 bytes HBZLTXJMIC(":,48*-)#  Try it online! The string of letters translates to the code section reversed and shifted up by 32. It's lucky all the characters used are in the correct range for shifting. ### Explanation: ( ) # Loop over the stack " # Shift stack left : # Duplicate the letter , # Print the letter 48*- # Subtract 32 from the ordinal value of the letter # # Comment out the newline #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+1+1+1+11+1+1+1+1+1+1+11+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+111+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+11+11+1+1+1+1+1+1+(|11+1<)$$1|1""+""*++"*;)(|1+11#(1)1""+""*+""*++;1#1+"//"\^\<11+*#()*+$$(%|()#(1)($)"1+1<#)\(&|()#11+"*"*"++;\"1+1<#)


Try it online!

• Congratulations! You beat me to the punch. Nice work!! – HighlyRadioactive Oct 6 '19 at 1:42

# 1+, 834 bytes

(|11+"*"+"1+\1+/)("|1/()11+^)(2|\""++1+/()""+^)++<+/(#|\##"\+;1#()\^\1#)+<+()()(")(2)(2)()()(")()(2)(")(2)()(")()(")()()()(2)(")()()()(2)()()(2)()(")()()()()(2)(2)(")()()()(2)()()(2)()(")(2)()(")(2)(")()(")()()()(2)(")(2)(2)()(")()(2)(")()()()(2)()()(2)()(")(")()(")()(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()(")(2)(")()()(2)()(")()(2)(")(2)(2)()()(")()(2)(")()(2)(")(2)()(")()()()()(2)(2)(")()(2)(")(")(")(2)()(")(2)(")()()(2)()(")()(2)(")()()()(2)(")()(2)(")()(2)(")(")(")()()()(2)()()(2)()(")(2)()(2)()(2)(")()()()(2)()(")(2)(")(2)()(")()()()()(2)(2)(")()(2)(")()()()(2)(")()()()(2)(")(2)()(")(2)(")()()(2)()(")()()()(2)(")(2)()(2)()(2)(")(")(2)(")(2)()(")()()(2)()(")()(2)(")()()()(2)(")()()()(2)()()(2)()(")()(2)(")()()()(2)(")(")()(2)(")(")(2)()()(")(")()(2)(")()()()(2)(")()()()(2)(")(2)()(2)()(2)(")(2)(")(2)()()(2)(")(")(#)@


Try it online!

Defines all the subroutines before the data section, then calls the (#) subroutine at the end of the data. Instead of using 1s followed by totalling 1+s, we define subroutines for initialisation ((")), which pushes a 2 to the stack, incrementing (()), and doubling plus 2 (ironically, (2)). All of these also push the characters used to call the subroutine to the top of the stack to print after printing the rest. We also offset the data by 32, since all values are above that.

This is most certainly suboptimal, especially since I've been steadily golfing it down from ~2000 bytes. I suspect it can be sub-500 eventually, or even lower with a different strategy.

Here's my program encoder, though it needs some post-fiddling with the first value to make sense.

# Whispers v2, 38 bytes

> "print('> %r\\n>> ⍎1'%a)"
>> ⍎1



Try it online!

Abuses the fact that there's an eval as Python command (⍎), which I can use to turn it into an arbitrary Python program. But of course, as a less cheaty feeling quine, there's:

# Whispers v2, 270 bytes

> [62, 62, 32, 34, 49, 34, 10, 62, 32, 34, 62, 32, 34, 10, 62, 62, 32, 51, 43, 50, 10, 62, 62, 32, 69, 97, 99, 104, 32, 54, 32, 49, 10, 62, 62, 32, 39, 82, 10, 62, 62, 32, 79, 117, 116, 112, 117, 116, 32, 52, 32, 53]
>> "1"
> "> "
>> 3+2
>> Each 6 1
>> 'R
>> Output 4 5



Try it online!

Which encodes the ordinal values of the rest of the program on the first line, then prints the list then the list converted to characters.

# BaCon, 54 bytes

Without using the SOURCE$variable, the smallest Quine is 55 bytes: s$="s$=%c%s%c:?34,s$,34 FORMAT s$":?34,s$,34 FORMAT s$ • please make the main part of the post the 55 byte noncheating quine – Destructible Lemon Oct 14 '16 at 21:05 • Done. I wonder why using 'SOURCE$' is cheating, looking at the other contributions? – Peter Oct 15 '16 at 20:05
• The other answers are also cheating. This challenge is over five years old; most answers were posted before we had clearly defined rules. Since last month, improper quines are officially forbidden in all challenges, even if the spec doesn't explicitly forbid them. – Dennis Oct 15 '16 at 20:13
• Thanks for pointing me to this page, I was unaware of it. – Peter Oct 16 '16 at 20:29

## (ucb)logo - 28 chars

to q
po "q
pr "q
bye
end

q


# Mathematica 17 19

ToString[#0][] & []

• Why Community Wiki? – MD XF Jun 12 '17 at 23:47

# Pyth, 11 bytes

jN*2]"jN*2]


Surprised this hadn't been posted yet :P

# ShapeScript, 16 bytes

'"%r"@%"0?!"'0?!


This answer is non-competing, since ShapeScript is a few years younger than this challenge.

Try it online!

### Verification

\$ shapescript quine.shape | diff -sq - quine.shape
Files - and quine.shape are identical


### How it works

'       Push a string that, when evaluated, does the following.
"%r"  Push this formatting string. %r gets replaced by a string
representation of the corresponding argument.
@     Swap the string that is being evaluated on top of the stack.
%     Apply formatting to the string on top of the stack.
"0?!" Push that string.
'
0?!     Push a copy of the previous string and evaluate it.


# ShapeScript, 32 bytes

'"'"'"'1?3?+3*2?+@+@+@#"0?!"'0?!


This version does not use string formatting. It's not particularly short, but I find it rather interesting.

Try it online!

### How it works

'"'     Push a double quote singleton string.
"'"     Push a single quote singleton string.
'       Push a string that, when evaluated, does the following:
1?3?    Copy the second and fourth topmost stack items.
This pushes a copy of the single, then the double quote.
+3*     Concatenate both and repeat the result three times.
2?+     Copy the third topmost stack item and append it to the string.
We now have a string of the first seven characters of the source.
@+      Swap with the string on the stack (the string that is being
evaluated) and concatenate.
@+      Swap with the original single quote and concatenate.
@#      Swap with the original double quote and discard it.
"0?!"   Push that string.
'
0?!     Push a copy of the above string and evaluate it.


# SWI-Prolog, 22 bytes

a :-
listing(a).



A surprisingly short and elegant solution.

The 8 spaces and the new line (the space in the last line is just to display the empty line, there is actually no space) are both required in SWI-Prolog because that is the formatting that listing displays in the interpreter.

# Brachylog, 3 bytes

@Qw


This expects no input or output, i.e. brachylog_main(_,_)..

@Q is the string "@Qw", and w is the write predicate.

### A 34 bytes quine without a specific built-in for quines

"~c~s~cS:[34:S:34]rw"S:[34:S:34]rw


This is a basic quine strategy applied to this language:

"~c~s~cS:[34:S:34]rw"              § Create a string containing the source code
§ ~c~s~c gets replaced by the arguments of predicate w
§ in their respective order in the list
§ ~c prints the arg as a char code, ~s as a string
S             § Call this string S
:[34:S:34]rw § Write the format S to the output with args " (34),
§ S and " replacing ~c, ~s and ~c respectively