# 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
• Did anybody notice that this is question 69? – aidan0626 Oct 24 '20 at 22:47

## Java, 190 Characters

class I{public static void main(String[]a){String s="class I{public static void main(String[]a){String s=%c%s%1$c;System.out.print(s.format(s,34,s));}}";System.out.print(s.format(s,34,s));}}  • Since ye olde Java SE 8, you can put static methods (such as main) in interfaces - no public. Also print and format methods can be collapsed into printf. – Tom Hawtin - tackline Oct 6 '18 at 23:08 # Reng v.1.3, 7 bytes Try it out here! "rYao;~  " begins a quote string, and reads all of those characters. r reverses the stack, and Y pushes the char code of ". a begins a one-way mirror loop, o outputs the character, and ; mirrors while the stack is truthy. After the zero is met, we advance to ~ and the program ends. # Reng v.2, 8 bytes {n6G*o}  This one is a little more interesting. {...} is a code block, and  executes a code block. n outputs the codeblock already on the stack, 6G* makes a  character (6*16 = 96), and o output's that. # Java 2146 2118 bytes A legitimate attempt at a quine. This was automagically generated. I could have robbed someone elses quining technique but decided against it. interface q{static void main(String[] args){char[] s={32,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,125,125,32,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,112,117,98,108,105,99,32,99,108,97,115,115,32,81,117,105,110,101,123,112,117,98,108,105,99,32,115,116,97,116,105,99,32,118,111,105,100,32,109,97,105,110,40,83,116,114,105,110,103,91,93,32,97,114,103,115,41,123,34,41,59,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,34,99,104,97,114,91,93,32,115,61,123,34,41,59,102,111,114,40,105,110,116,32,105,61,48,59,105,60,115,46,108,101,110,103,116,104,45,49,59,105,43,43,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,105,93,43,34,44,34,41,59,125,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,40,105,110,116,41,115,91,115,46,108,101,110,103,116,104,45,49,93,43,34,125,59,34,41,59,102,111,114,40,99,104,97,114,32,99,58,32,115,41,123,83,121,115,116,101,109,46,111,117,116,46,112,114,105,110,116,40,99,41,59,125,125,125};System.out.print("interface q{static void main(String[] args){");System.out.print("char[] s={");for(int i=0;i<s.length-1;i++){System.out.print((int)s[i]+",");}System.out.print((int)s[s.length-1]+"};");for(char c: s){System.out.print(c);}}}  # Julia, 36 bytes (~=:@printf "(~=:%s)|>eval" ~)|>eval  Try it online! ### Background Unlike many other languages, Julia's eval doesn't work as expected with a string; for example, eval("print(42)") just returns the string print(42). To actually executed print(42) with eval;, we have to pass an Expr to eval. This can be done by invoking parse on a string (e.g., eval(parse("print(42)"))) or by passing an Expr literal to eval (e.g., eval(:(print(42))). Now, while : is a unary operator and :print works fine on its own, :print(42) does not, as it is parsed as (:print)(42), making all parentheses in :(print(42)) mandatory. However, if we use the macro @printf instead, the parsing rules change, and :@printf(42) works as intended. Also, macro calls also do not require parentheses, and :@printf 42 saves one byte over :(print(42)). ### How it works :@printf "(~=:%s)|>eval" ~ constructs the Expr that calls @printf with the specified format string and additional argument ~. Here, ~ is simply a variable reference; the name is arbitrary. ~=<Expr> saves the generated Expr in the variable ~, which will be accessible when the Expr is evaluated. Finally, (<assigment>)|>eval calls eval with the return value of the assignment, i.e., the Expr that was assigned to ~. # Common Lisp - 73 35 Thanks to reader variables written #n= and #n#, with n an integer, Lisp code can be self-referential. Also, the printing functions can emit such reader variables when told to handle circular structures. The WRITE function accepts a :circle parameter for that purpose. It also returns the value being printed, which means that we have to globally set *PRINT-CIRCLE* to T (the initial, standard value is NIL), otherwise the REPL would report a stack-overflow exception when printing that value. Initializing the variable takes a lot of bytes and so the shorter solution is to return another value: #1=(PROGN (WRITE '#1# :CIRCLE T) T)  # Scala, 56 bytes val s="val s=%c%s%c;printf(s,34,s,34)";printf(s,34,s,34)  First defines s as val s=%c%s%c;printf(s,34,s,34), then prints it formatted with double quotes (ascii 34) and itself. # Dart, 185 bytes main(){var c=new String.fromCharCode(34);var l=["main(){var c=new String.fromCharCode(34);var l=[","];print(l[0]+c+l[0]+c+','+c+l[1]+c+l[1]);}"];print(l[0]+c+l[0]+c+','+c+l[1]+c+l[1]);}  # Dip, 10 bytes "N+|+"N+|+  Explanation: "N+|+" Push string N+ Add " on the left side of the string |+ Duplicate and concatenate  # Zetaplex, 13 bytes "Sr34SZOsDrFe  Zetaplex is a variant of gammaplex. In it, commands are pairs of chars and act on an infinite stack. # stacked, 16 bytes Try it here! [put ':!' put]:!  [put ':!' put] is a func, which is pushed to the stack. : duplicates it, and ! executes it, which prints the function, then :!. # Racket, 90 bytes ((lambda (x) (display (list (~a x) (~v x)))) '(lambda (x) (display (list (~a x) (~v x)))))  • You can remove unnecessary spaces to golf bytes. I'm not sure what spaces you can remove (cause I use Clojure), but there's definitely spaces that you can remove. – clismique Jan 23 '17 at 9:37 • Not in this case, because the input has to match the printed output – Matthew Butterick Jan 23 '17 at 13:12 • Oh... yeah, whoops. I'm just looking at the spaces and thinking that they can be golfed somehow. Well, TIL. – clismique Jan 23 '17 at 22:00 # Pip, 15 bytes V Y"V Y.RPy"  The code includes a trailing newline. Try it online! ### Explanation  Y"..." Yank this string into the y variable V and evaluate it  which executes this: V Y A Pattern literal (for our purposes, a string-like object without "") . to which we concatenate RPy repr(y), which wraps y in ""  The result is autoprinted with a trailing newline. ### Bonus submission, 18 bytes The above is the shortest Pip quine that I've found, but unfortunately it doesn't do so well when you try to modify it for other quine challenges. I have found this one to be more payload-friendly: Y"Y yRsRPy"yRsRPy Y"Y yRsRPy" Yank that string into y yRsRPy Take y and replace space with repr(y)  # k, 48 bytes This is, of course, ignoring the trivial quines, such as () or 1. {}0:(c$34)/{(x;x;())}"{}0:(c$34)/{(x;x;())}"  Try it out. # Scala, 540 Bytes object Q { def main(a:Array[String]):Unit={ val d=Seq( "object Q {", "def main(a:Array[String]):Unit={", "val d=Seq(", "val c=println(_:String)", "val b=(x:Int)=>x.toChar.toString", "d take 3 map c", "val a=d.zipWithIndex.map(x=>b(34)+x._1+b(34)+(if(x._2==d.size-1)b(9).drop(1)else b(44)))", "a.map(c)", "c(b(41))", "d.drop(3).map(c)", "c(b(125))", "c(b(125))" ) val c=println(_:String) val b=(x:Int)=>x.toChar.toString d take 3 map c val a=d.zipWithIndex.map(x=>b(34)+x._1+b(34)+(if(x._2==d.size-1)b(9).drop(1)else b(44))) a.map(c) c(b(41)) d.drop(3).map(c) c(b(125)) c(b(125)) } }  Can probably be improved. I decided to call it quits for now as it is 5 in the morning. I think something that can be changed to make this smaller is to encode the d value in some other way other than a sequence of strings. I haven't thought of a cool way to do it yet, though. This would also add to the obfuscation part of the challenge. ## PowerShell, 24 bytes, 21 characters .($s={".($s={$s})"})


I'm going to attempt to explain this, but be forewarned that I'm terrible at explaining myself.

This code sets $s to the following: ".($s={$s})"  This recursively sets the variable$s (the first $s is a plain string, but the second$s is the variable $s) in itself and then the block inside parentheses echoes$s, which at time of execution will be the following:

.($s={".($s={$s})"})  # Hack 60 bytes <?hh printf($p='<?hh printf($p=%c%s%c,39,$p,39);',39,$p,39);  Only language I could think to do it in that I didn't see on the list. # Brainfuck, 404 bytes ->++>+++>+>+>+++>>>>>>>>>>>>>>>>>>>>>>+>+>++>+++>++>>+++>+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+>>+++>>>>+++>>>+++>+>>>>>>>++>+++>+++>+>>+++>+++>+>+++>+>+++>+>++>+++>>>+>+>+>+>++>+++>+>+>>+++>>>>>>>+>+>>>+>+>++>+++>+++>+>>+++>+++>+>+++>+>++>+++>++>>+>+>++>+++>+>+>>+++>>>+++>+>>>++>+++>+++>+>>+++>>>+++>+>+++>+>>+++>>+++>>+[[>>+[>]+>+[<]<-]>>[>]<+<+++[<]<<+]>>>[>]+++>+[+[<++++++++++++++++>-]<++++++++++.<]  Try it online! I found this quine here; I didn't write it myself. I'm currently trying to understand how it works exactly to add an explanation. # Forth, 105 bytes S" 2dup 34 83 emit emit space type 34 emit space type" 2dup 34 83 emit emit space type 34 emit space type  Try it online ### Explanation: S" 2dup 34 83 emit emit space type 34 emit space type" \ push a string 2dup \ duplicate string 34 83 emit emit space \ print 'S" ' type \ print string 34 emit space \ print '" ' type \ print string duplicate  # Standard ML (MLton), 60 bytes ";str(chr 34)^it;print(it^it);";str(chr 34)^it;print(it^it);  Try it online! I previously thought this kind of quine would only work when interpreted, e.g. by the Moscow ML interpreter. However, MLton happily compiles it to a standalone executable, so I guess it's fine. ### How it works Usually one writes val x = <some expression> ; in a SML interpreter to bind the identifier x to result of the evaluation of <some expression>. If the val x = part is omitted, the result is bound to the implicit result identifier it instead. The quine consists of three declarations: ";str(chr 34)^it;print(it^it);";  A single string, so it = ";str(chr 34)^it;print(it^it);". str(chr 34)^it;  chr 34 yields the 34th ASCII-character, which is ". str converts the character into a string and the ^-operator performs string concatenation, thus it = "\";str(chr 34)^it;print(it^it);". print(it^it);  it^it now yields an escaped string version of the source code which is printed to STDOUT with print. # COBOL, 18808 bytes This was posted to the mvsHelp forum in 2004. Spaces necessary.  IDENTIFICATION DIVISION. PROGRAM-ID. GRICE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SPECIAL-NAMES. SYMBOLIC CHARACTERS FULL-STOP IS 76. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT OUTPUT-FILE ASSIGN TO OUTPUT1. DATA DIVISION. FILE SECTION. FD OUTPUT-FILE RECORDING MODE F LABEL RECORDS OMITTED. 01 OUTPUT-RECORD PIC X(80). WORKING-STORAGE SECTION. 01 SUB-X PIC S9(4) COMP. 01 SOURCE-FACSIMILE-AREA. 02 SOURCE-FACSIMILE-DATA. 03 FILLER PIC X(40) VALUE " IDENTIFICATION DIVISION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " PROGRAM-ID. GRICE. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ENVIRONMENT DIVISION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " CONFIGURATION SECTION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " SPECIAL-NAMES. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " SYMBOLIC CHARACTERS FULL-STOP". 03 FILLER PIC X(40) VALUE " IS 76. ". 03 FILLER PIC X(40) VALUE " INPUT-OUTPUT SECTION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " FILE-CONTROL. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " SELECT OUTPUT-FILE ASSIGN TO ". 03 FILLER PIC X(40) VALUE "OUTPUT1. ". 03 FILLER PIC X(40) VALUE " DATA DIVISION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " FILE SECTION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " FD OUTPUT-FILE ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " RECORDING MODE F ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " LABEL RECORDS OMITTED. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " 01 OUTPUT-RECORD ". 03 FILLER PIC X(40) VALUE " PIC X(80). ". 03 FILLER PIC X(40) VALUE " WORKING-STORAGE SECTION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " 01 SUB-X ". 03 FILLER PIC X(40) VALUE " PIC S9(4) COMP. ". 03 FILLER PIC X(40) VALUE " 01 SOURCE-FACSIMILE-AREA. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " 02 SOURCE-FACSIMILE-DATA. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " 03 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X(40) VALUE ". 03 FILLER PIC X(40) VALUE " 02 SOURCE-FACSIMILE-TABLE RE". 03 FILLER PIC X(40) VALUE "DEFINES ". 03 FILLER PIC X(40) VALUE " SOURCE-FACSIMILE-DATA". 03 FILLER PIC X(40) VALUE ". ". 03 FILLER PIC X(40) VALUE " 03 SOURCE-FACSIMILE OCCU". 03 FILLER PIC X(40) VALUE "RS 68. ". 03 FILLER PIC X(40) VALUE " 04 SOURCE-FACSIMILE-". 03 FILLER PIC X(40) VALUE "ONE PIC X(40). ". 03 FILLER PIC X(40) VALUE " 04 SOURCE-FACSIMILE-". 03 FILLER PIC X(40) VALUE "TWO PIC X(40). ". 03 FILLER PIC X(40) VALUE " 01 FILLER-IMAGE. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " 02 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X(15) VALUE SPACES. ". 03 FILLER PIC X(40) VALUE " 02 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X VALUE QUOTE. ". 03 FILLER PIC X(40) VALUE " 02 FILLER-DATA ". 03 FILLER PIC X(40) VALUE " PIC X(40). ". 03 FILLER PIC X(40) VALUE " 02 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X VALUE QUOTE. ". 03 FILLER PIC X(40) VALUE " 02 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X VALUE FULL-STOP. ". 03 FILLER PIC X(40) VALUE " 02 FILLER ". 03 FILLER PIC X(40) VALUE " PIC X(22) VALUE SPACES. ". 03 FILLER PIC X(40) VALUE " PROCEDURE DIVISION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MAIN-LINE SECTION. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ML-1. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " OPEN OUTPUT OUTPUT-FILE. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE 1 TO SUB-X. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ML-2. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE (SUB-X)". 03 FILLER PIC X(40) VALUE " TO OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " IF SUB-X < 19 ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ADD 1 TO SUB-X ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " GO TO ML-2. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE 1 TO SUB-X. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ML-3. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE (20) TO". 03 FILLER PIC X(40) VALUE " OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE-ONE (SU". 03 FILLER PIC X(40) VALUE "B-X) TO FILLER-DATA. ". 03 FILLER PIC X(40) VALUE " MOVE FILLER-IMAGE TO OUTPUT-R". 03 FILLER PIC X(40) VALUE "ECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE (20) TO". 03 FILLER PIC X(40) VALUE " OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE-TWO (SU". 03 FILLER PIC X(40) VALUE "B-X) TO FILLER-DATA. ". 03 FILLER PIC X(40) VALUE " MOVE FILLER-IMAGE TO OUTPUT-R". 03 FILLER PIC X(40) VALUE "ECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " IF SUB-X < 68 ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ADD 1 TO SUB-X ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " GO TO ML-3. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE 21 TO SUB-X. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ML-4. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " MOVE SOURCE-FACSIMILE (SUB-X)". 03 FILLER PIC X(40) VALUE " TO OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " WRITE OUTPUT-RECORD. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " IF SUB-X < 68 ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ADD 1 TO SUB-X ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " GO TO ML-4. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " ML-99. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " CLOSE OUTPUT-FILE. ". 03 FILLER PIC X(40) VALUE " ". 03 FILLER PIC X(40) VALUE " STOP RUN. ". 03 FILLER PIC X(40) VALUE " ". 02 SOURCE-FACSIMILE-TABLE REDEFINES SOURCE-FACSIMILE-DATA. 03 SOURCE-FACSIMILE OCCURS 68. 04 SOURCE-FACSIMILE-ONE PIC X(40). 04 SOURCE-FACSIMILE-TWO PIC X(40). 01 FILLER-IMAGE. 02 FILLER PIC X(15) VALUE SPACES. 02 FILLER PIC X VALUE QUOTE. 02 FILLER-DATA PIC X(40). 02 FILLER PIC X VALUE QUOTE. 02 FILLER PIC X VALUE FULL-STOP. 02 FILLER PIC X(22) VALUE SPACES. PROCEDURE DIVISION. MAIN-LINE SECTION. ML-1. OPEN OUTPUT OUTPUT-FILE. MOVE 1 TO SUB-X. ML-2. MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. IF SUB-X < 19 ADD 1 TO SUB-X GO TO ML-2. MOVE 1 TO SUB-X. ML-3. MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. MOVE SOURCE-FACSIMILE-ONE (SUB-X) TO FILLER-DATA. MOVE FILLER-IMAGE TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. MOVE SOURCE-FACSIMILE (20) TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. MOVE SOURCE-FACSIMILE-TWO (SUB-X) TO FILLER-DATA. MOVE FILLER-IMAGE TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. IF SUB-X < 68 ADD 1 TO SUB-X GO TO ML-3. MOVE 21 TO SUB-X. ML-4. MOVE SOURCE-FACSIMILE (SUB-X) TO OUTPUT-RECORD. WRITE OUTPUT-RECORD. IF SUB-X < 68 ADD 1 TO SUB-X GO TO ML-4. ML-99. CLOSE OUTPUT-FILE. STOP RUN.  # Bash, 54 52 bytes -2 thanks to Ørjan Johansen a=\' b='a=\$a b=aba\;eval echo$b';eval echo$b

• The spaces after the semicolons seem unnecessary. – Ørjan Johansen May 27 '17 at 2:06
• @ØrjanJohansen Oh, I completely forgot to golf that part! Thanks :D – MD XF May 27 '17 at 2:27
• You forgot to include the new length. – Ørjan Johansen May 27 '17 at 2:39
• @ØrjanJohansen Is there any limit to how helpful you can be :P – MD XF May 27 '17 at 2:40

# ><>, 42 Bytes

'r3d*>l?\ao"/o \     "ooooooooo;
\ o/


Try it online

# shortC, 38 28 bytes

AR_="AR_=%c%s%1\$c,34,_",34,_


Try it online!

# Bob, 1221 bytes

c=","; n="\n"; q="\""; s="\\";
v=\[
"c=\",\"; n=\"\\n\"; q=\"\\\"\"; s=\"\\\\\";",
"v=\\[",
"define prtQuote(str) {",
" local j,t,v;",
" stdout.Display(q);",
" for (j=0; j<str.size; j++) {",
"  t = str.Substring(j,1);",
"  if (t==q) { stdout.Display(s); }",
"  if (t==s) { stdout.Display(s); }",
"  stdout.Display(t);",
" }",
" stdout.Display(q);",
"}",
"for(i=0; i<2; i++){ stdout.Display(v[i]); stdout.Display(n); }",
"for(i=0; i<v.size-1; i++){ prtQuote(v[i]); stdout.Display(c); stdout.Display(n); }",
"prtQuote(v[v.size-1]); stdout.Display(n);",
"stdout.Display(v[v.size-1]); stdout.Display(n);",
"for(i=2; i<v.size-1; i++){ stdout.Display(v[i]); stdout.Display(n); }",
"];"
];
define prtQuote(str) {
local j,t,v;
stdout.Display(q);
for (j=0; j<str.size; j++) {
t = str.Substring(j,1);
if (t==q) { stdout.Display(s); }
if (t==s) { stdout.Display(s); }
stdout.Display(t);
}
stdout.Display(q);
}
for(i=0; i<2; i++){ stdout.Display(v[i]); stdout.Display(n); }
for(i=0; i<v.size-1; i++){ prtQuote(v[i]); stdout.Display(c); stdout.Display(n); }
prtQuote(v[v.size-1]); stdout.Display(n);
stdout.Display(v[v.size-1]); stdout.Display(n);
for(i=2; i<v.size-1; i++){ stdout.Display(v[i]); stdout.Display(n); }


source

# RProgN 2, 3 bytes


«Ø


Try it online!

This code does nothing with the first line, then, pushes the function «Ø. As « is unmatched, it falls through and executes the contents. Ø then pushes an empty string. The implicit printing behaviour first prints the empty string, then the function, giving our source code.

# 4 bytes

«•.


Try it online!

This uses the fall through behavoir of the last quine, but ensures "quine" behavoir a different way. • pushes a space, . concatenates it, which gives our code.

# 6 bytes

{{.}{


Try it online!

This uses a different fallthrough behavoir. {{.} pushes a funciton, then {, with an unmatched }, fails and moves the IP back to index 1, which skips the function definition, and runs its contents instead. (backtick){ pushes { as a string, then . appends it to the function, stringifying it. } then terminates the program, and the string is implicitely output.

# OML, 20 bytes

"lK(34Tos)"lK(34Tos)


Try it online!

This was an interesting process. I initially started off with the classic data-decoder method of quining. That is, one devotes one section of the program to encoding the decoder, and another section to generate the data representation and decode the data. This came out to look like this (51 bytes):

'\'l'K'l'2'/'['('''''o'o')']'('o')\lKl2/[(''oo)](o)


Where the data section looks like:

'\'l'K'l'2'/'['('''''o'o')']'('o')


which pushes each character after a '. The decoder looks like this:

\lKl2/[(''oo)](o)
\                  reverse stack
lK                duplicate stack
l2/[            copy the duplication into a new stack
(    )      while there are characters on this stack:
''o          output a single quote
o         and the character
(o)  output all characters on this stack


This can be improved slightly by replacing (o) with ls (48 bytes):

'\'l'K'l'2'/'['('''''o'o')']'l's\lKl2/[(''oo)]ls


However, OML also has a length-encoded string construct. Let's say the string is "xyz". This is effectively 'x'y'z3, since there are three characters in the string. We can use s to print this string, but we still need to generate the quote characters. With all this in mind, I was able to devise the following approach (26 bytes):

"lK34Tos34Tos"lK34Tos34Tos


Simply put, this puts the "string" "lK34Tos34Tos" to the stack, then performs the following actions:

lK34Tos34Tos
lk            duplicate the stack (in this case, the string)
34To        output a quotation mark "
s       output the string
34To   output another quotation mark "
s  output the string again


We obtain our final version by noting that the structure 34Tos is repeated twice. We can use a while loop to produce the current answer.

# Funky, 21 bytes

f=@writef=[f]f()f()


Try it online!

or, if Functions are allowed...

# Funky, 9 bytes

f=@'f='+f


The second of these defines a function f which returns the string f=@'f='+f, the first however is a full program.

Try it online!

# Aubergine, 21 bytes

-a1+a1=oA=Bi-BA:bB=ia


This program ends with a trailing tab character.

• Tab character?. – CalculatorFeline Jan 26 '17 at 21:47
• I wrote this program in November 2015. I could have sworn I'd posted it here already. Anyway thanks for posting it and no thanks for not giving me credit. – quintopia Dec 15 '17 at 6:37
• That doesn't make sense, you didn't post it on here, so how would I know you already wrote it lmao – Oliver Ni Dec 16 '17 at 7:02

# Locksmith, 201 bytes

070405000400080701090704000102010702070000080006030109000107020001020106070707040507040001020107020700000800060301090001070200010201067450408719740121727008063190172012167774574012172700806319017201216


Try it online!

Formatted:

0704050004000807010907040001020107020700000800060301090001070200010
2010607070704050704000102010702070000080006030109000107020001020106
7450408719740121727008063190172012167774574012172700806319017201216


This consists of two parts: the data section and the decoder. The data section is simply each byte of the encoder prefixed with a 0 (which is the command to push that number). The decoder is:

74              // push stack length
5               // that many times:
0408719      // output a 0
74012172     // bring bottom of stack to the top
700806319    // output this without popping
0172         // swap top two (brings length to top)
0121         // decrement
6               // close loop

7774            // pop counter, push length again
5
74012172     // bring bottom to top
700806319    // output
0172         // bring length to top
0121         // decrement
6               // close loop


# Swift 4, 120 bytes

import Foundation;let q="import Foundation;let q=%c%@%c;print(String(format:q,34,q,34))";print(String(format:q,34,q,34))


Try See it online!

Since this code imports Foundation`, and the Swift corelibs can be a little quirky in non-macOS environments, you might not be able to run it (it doesn't work in TIO, or IBM's Swift Sandbox). If, however, you have a macOS environment, then you should be just fine.