242
\$\begingroup\$

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;

var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";var COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk";var answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;function answersUrl(index){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}
function commentUrl(index,answers){return"https://api.stackexchange.com/2.2/answers/"+answers.join(';')+"/comments?page="+index+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}
function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){answers.push.apply(answers,data.items);answers_hash=[];answer_ids=[];data.items.forEach(function(a){a.comments=[];var id=+a.share_link.match(/\d+/);answer_ids.push(id);answers_hash[id]=a});if(!data.has_more)more_answers=!1;comment_page=1;getComments()}})}
function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(data){data.items.forEach(function(c){if(c.owner.user_id===OVERRIDE_USER)
answers_hash[c.post_id].comments.push(c)});if(data.has_more)getComments();else if(more_answers)getAnswers();else process()}})}
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}
function process(){var valid=[];answers.forEach(function(a){var body=a.body;a.comments.forEach(function(c){if(OVERRIDE_REG.test(c.body))
body='<h1>'+c.body.replace(OVERRIDE_REG,'')+'</h1>'});var match=body.match(SCORE_REG);if(match)
valid.push({user:getAuthorName(a),size:+match[2],language:match[1],link:a.share_link,})});valid.sort(function(a,b){var aB=a.size,bB=b.size;return aB-bB});var languages={};var place=1;var lastSize=null;var lastPlace=1;valid.forEach(function(a){if(a.size!=lastSize)
lastPlace=place;lastSize=a.size;++place;var answer=jQuery("#answer-template").html();answer=answer.replace("{{PLACE}}",lastPlace+".").replace("{{NAME}}",a.user).replace("{{LANGUAGE}}",a.language).replace("{{SIZE}}",a.size).replace("{{LINK}}",a.link);answer=jQuery(answer);jQuery("#answers").append(answer);var lang=a.language;lang=jQuery('<i>'+a.language+'</i>').text().toLowerCase();languages[lang]=languages[lang]||{lang:a.language,user:a.user,size:a.size,link:a.link,uniq:lang}});var langs=[];for(var lang in languages)
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> 

\$\endgroup\$
4
  • 6
    \$\begingroup\$ Do you not mean, "Golf you a quine for greater good!"? \$\endgroup\$ May 3, 2011 at 2:49
  • 64
    \$\begingroup\$ @muntoo it's a play on "Learn you a Haskell for Great Good". \$\endgroup\$ May 3, 2011 at 2:52
  • 26
    \$\begingroup\$ Did anybody notice that this is question 69? \$\endgroup\$
    – aidan0626
    Oct 24, 2020 at 22:47
  • \$\begingroup\$ @aidan0626 🤢🤢🤮🤮 \$\endgroup\$ Oct 9 at 9:14

450 Answers 450

1
7 8
9
10 11
15
3
\$\begingroup\$

2sable, 10 bytes

44186D15B

Try it online!

This uses the same strategy as its parent language 05AB1E, but beats it by not having to join afterwards.

Explanation

44186      Push 44186
     D     Duplicate
      15B  Convert to base 15
           Implicitly print the stack
\$\endgroup\$
3
\$\begingroup\$

R, 44 41 bytes

crossed out 44 is still regular 44 ;(

-3 bytes thanks to Dominic van Essen

Works on R Version 3.6.2 and greater (thanks to Giuseppe for figuring out the versions).

`+` <-
function(x)cat(dump("+",""),1)
+ 1

Try it online!

This is 3 6 bytes shorter than the previous shortest quine by JAD.

Note that TIO currently uses R version 3.5.2, and thus adds some spaces and newlines to the output, but my local install of R version 3.6.3 does not, and gives the exact correct output.

\$\endgroup\$
15
  • 1
    \$\begingroup\$ IIRC TIO calls R by using Rscript as seen here, not sure if that's the difference. \$\endgroup\$
    – Giuseppe
    Aug 4, 2020 at 15:48
  • \$\begingroup\$ Nice! And you can even shed 2 more bytes to 42 bytes (also works on R installation but not properly on TIO or RScript). \$\endgroup\$ Aug 4, 2020 at 17:51
  • \$\begingroup\$ @DominicvanEssen Neat, thanks! \$\endgroup\$ Aug 4, 2020 at 21:46
  • \$\begingroup\$ Some digging in R news shows that since TIO's R install (3.5.2), there's been a change to dump as of version 3.6.2: see this edition of R News. I have 3.6.1 on my machine and it prints the function() and its body on separate lines. \$\endgroup\$
    – Giuseppe
    Aug 4, 2020 at 22:03
  • \$\begingroup\$ @Giuseppe Thanks for working that out! \$\endgroup\$ Aug 5, 2020 at 5:39
3
\$\begingroup\$

Jq -rn, 18 bytes

"|@json+."|@json+.
"|@json+."         # the string
          |        # through the filter
           @json   # json encoded
                +  # concatenated with
                 . # itself
\$\endgroup\$
3
\$\begingroup\$

05AB1E, 13 bytes

"34çì«"34çì«

Try it online!

"..."34çì«  # trimmed program
"..."       # push literal...
        ì   # prepended with...
       ç    # character with codepoint...
     34     # literal...
         «  # concatenated with...
            # (implicit) itself
            # implicit output
\$\endgroup\$
3
\$\begingroup\$

Vyxal, 10 8 bytes

`:qp`:qp

Try it Online!

-2 thanks to a stone arachnid

Explained

`:qp`:qp
`:qp`    # the string ":qp"
     :q  # surrounded in backticks
       p # and prepended to itself
\$\endgroup\$
3
  • 2
    \$\begingroup\$ 8 bytes: Try it Online! \$\endgroup\$ May 26, 2021 at 3:43
  • \$\begingroup\$ Does this count? \$\endgroup\$
    – user
    May 30, 2021 at 16:13
  • 1
    \$\begingroup\$ @user no, it doesn't \$\endgroup\$
    – lyxal
    May 30, 2021 at 22:30
3
\$\begingroup\$

Unix Executable, 10 bytes

#!/bin/cat

When run with something such as ./file, it will actually call /bin/cat ./file (because of the shebang), which prints the file's contents.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This is not a proper quine, meaning it prints its own source code. Good try, though. With bash, I'd omit the sha-bang statement and jump straight to the cat. This would do: cat $0. In bash, sha-bang can be suppressed, and the script is treated as generic system commands. But this does not qualify as well. (I don't know if this works on other shells.) \$\endgroup\$ Jul 31, 2021 at 4:40
3
\$\begingroup\$

Nim, 87 bytes

import strutils;let s="import strutils;let s=$1$2$1;echo s%[$$'$1',s]";echo s%[$'"',s]

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Pxem (esolang-box notation), 21 bytes.

I originally posted this as a cheating quine, which I noticed it disqualified for the problem.

.fak.-.f.p
.fak.-.f.p

Try it online!

How it works

In this notation,

  • 1st line is main routine.
  • .f is for push its own content from 2nd to final lines.

ak.- is an idiom to push LF; .p pops each item to print them.

\$\endgroup\$
3
\$\begingroup\$

Alumin, 350 bytes

hhhhhhhhhhhhh hhhh hhhhhhhhhhhhhhhhh hhhhhhhh hhhhhhhhhhhh hhhh hhhhhhhhhhhhhhhhhhhh hhhhhhhh h hhhh hhhhhhhhhhhhhhhhhhhh hhhhhhhhhhhh h hhhhhhhhhhhhhhh hhh hhhhhhhhhhhhhhhh hhhhhhhhhhhh h hhhh h hhhh hhhhhhhhhhhhhhhhhhhh hhhh h hhhh hhhhhhhhhhhhhhh hhhh hhhh h h h hhhhhhhhhhhhh hhhhhh hhhhhhhhhhhhhhh hhhhhh h mdqhldthadtlaocpladadtdadoddaaamfof97

Try it online!

Alumin is a stack-based language that only executes the lowercase alphabetical characters.

Explanation:

hhh...     Each series of `h`s represents a single alphabetical character. h=a, hh=b, hhh=c etc.

m          Map each element to
 d         Duplicate the element as a loop counter
 q         While that element is positive
  h        Push 1
  l        Push length of stack (3)
  dt       Square (3*3=9)
  ha       Add 1 (9+1=10)
  dt       Square (10*10=100)
  la       Add length of stack (100+4=104)
  o        And output ('h')
  c        And subtract the first 1 from the counter
 p         End loop
 la        Add length to the end result (0+2=2)
 da        Double (2+2=4)
 dt        Square (4*4=16)
 da        Double (16+16=32)
 do        Dupe and output (32)
 ddaa      Triple (32+32+32=96)
 a         And add to the original value to get the ascii character
m
fof        And print each value
97         The program prints the last remaining value automatically
\$\endgroup\$
3
\$\begingroup\$

Pari/GP, 28 bytes

(()->print1("("self")()"))()

Try it online!

\$\endgroup\$
3
\$\begingroup\$

Zsh, 40 bytes

s='s=\47%s\47;printf $s $s';printf $s $s

Try it online!

Until recently, this was the shortest universally trivially modifiable quine. Uses no external commands (printf is a builtin).

(Lesson learnt: don't describe your answer as the shortest possible.)

\$\endgroup\$
3
\$\begingroup\$

Joy, 32 bytes

[put "x." putchars 10 putch] x.

Try it online!

Joy is a stack-based language. It has an interesting operation, x, which means executing a block without popping it. So [P] x is equivalent to [P] P. This is useful for writing quines.

\$\endgroup\$
4
  • \$\begingroup\$ The second time I've seen Joy, after the appearance in your article about Esolangs. \$\endgroup\$ Apr 15, 2022 at 5:23
  • 1
    \$\begingroup\$ Let's see some DipDup answers too! \$\endgroup\$ Apr 15, 2022 at 5:26
  • \$\begingroup\$ As a sidenote, are you still in the CGoL community? \$\endgroup\$ Apr 15, 2022 at 5:27
  • 1
    \$\begingroup\$ @null I'm not active in the forum, just occasionally search the word "rlifesrc" to see if anyone has found a bug. \$\endgroup\$
    – alephalpha
    Apr 15, 2022 at 5:44
3
\$\begingroup\$

Pyxplot 0.8.4, 62 bytes

q="'";Q='"';s='pr"q=",Q,q,Q,";Q=",q,Q,q,";s=",q,s,q,";@s"';@s

This quine makes use of the macro expansion operator @ to execute the code stored in the string s. Both quote characters have to be extracted to variables because there is no way to get one without the other (not counting backslash escapes, which don't help here).

Fun fact: replace pr with print and @s with eval s and you have a not-so-golfy Ruby quine.

\$\endgroup\$
3
\$\begingroup\$

Fig, \$14\log_{256}(96)\approx\$ 11.524 bytes

"
h+C34"
h+C34

Try it online!

\$\endgroup\$
0
3
\$\begingroup\$

pl – Perl One-Liner Magic Wand, 22 bytes

Very late to the party, just for fun. This decades old Perl wrapper, was only released into the wild when Corona went viral.

The 3rd quine in the blog is the actual golf. Of interest here is the 2nd 1-letter alias variant. It's essentially the same as the Perl one, which it beats by 6 bytes. As on many examples on that page, hover the ▶ button, or the blue code box, to see the result.

&f(qw(&f(qw(%s)x2))x2)
\$\endgroup\$
4
  • \$\begingroup\$ Welcome to the site and nice first answer! The "default" online interpreter we use on this site, Try It Online!, has pl listed, so I've edited your answer slightly so it's closer to our standard format. Please, feel free to check out our main questions page for more challenges you can attempt! \$\endgroup\$ Oct 15, 2020 at 21:00
  • \$\begingroup\$ @caird-coinheringaahing Thanks, but that's a different pl. It implements some weird undocumented highly specialized language. It has nothing to do with Perl, other than being implemented in it. It's a total coincidence that it spews out my quine ;-) \$\endgroup\$
    – Daniel
    Oct 15, 2020 at 21:09
  • \$\begingroup\$ Huh, a very weird coincidence. My mistake, I've rolled back my edit \$\endgroup\$ Oct 15, 2020 at 21:10
  • \$\begingroup\$ @caird-coinheringaahing Actually not such a weird coincidence. Apart from the few (code golf only?) tasks that other pl language is capable of performing, everything you throw at it seems to be a quine. Like calling cat a language. \$\endgroup\$
    – Daniel
    Oct 16, 2020 at 21:49
3
\$\begingroup\$

Functional(), 904 880 846 768 716 692 684 662 605 602 bytes

),$,$$,($(8,( $(($(<,$(,,,)),($(4,$(9,,)),($(9,$(,,0,,)),($(0,$()),$ 4)(((0,9,,$)(((,)(( $(($($$,( 9((()(9($ <($ 4(8(, 4))))))$$),, $))(( $(,(,$),,(),, 9,, 0,, $,, 4,,(,())))))),(()($$())(8(9(9(8(4(4(8(9(8(8(<(9(9(9(9(9(9(9(8(<(8(<(<(4($,0(<(<(4(0(<(<(0($,0(<(<(9($,0(<(<(9(8(<(<(9(4(<(8(<(8(4(0(8(8(9(9(4(0(<(<(9(4(4(9(9(9(9(9(9(4($,0(<(8(8($,8(4($,0(4(8(<($,0(4(8(9($,8(9(8(8(8(9($,0(8(<(4(4(8(4(8(8(4(0(8(8(9(<(8(8(8(9(4(<(<(9($,<(0($,8(8(8(9(4($,0(4(<(9(9(8(4(<(0($,8(4(8(<(9(9(<(<(0($,<(<(8(4(<(9($,8(4(8(<(9(9(<(<(9($,8(4(<(4($,8(4(8(<(9(9(<(<(<(8(4(<(<($,8(4(8(8(4(0(8(<(8($,8(4(8(<(4(4(<(4(<(9(

Try it online!
Try the 605B version online!
Try the 662B version online!
Try the 684B version online!
Try the 692B version online!
Try the 716B version online!
Try the 768B version online!
Try the 846B version online!
Try the 880B version online!
Try the 904B version online!

This code comes from a generator code below;

),1,P,
:(h,
  & 1(
    :(l,1(>,>)),
    :(d,1(i,>)),
    :(i,1(>,`,>)),
    :(`,1()),
    1 d
  )(
    &(`,i,X)(
      &(>)(
        & 1(
          :(P,
            & i(
              &()(
                i(1 l(1 d(h(> d))))
              )
            )P
          ),
          > 1
        )
      )(
        & 1(
          >(X),>(),> i,> `,> 1,> d,>(>())
        )
      )
    )
  )
),
&()(
  P()
)(

h(i(
  i(h(d(d(
h(i(h(h(
l(i(
  i(
    i(
      i(
        i(
          i(i(h(l(h(l(l(d(1,`(l(l(d(`(l(l(`(1,`(l(l(i(1,`(l(l(i(h(l(l(i(d(l(h(l(
        h(d(`(h(
      h(i(
        i(
          d(`(l(
          l(i(
            d(d(i(
              i(
                i(i(i(i(d(1,`(l(h(h(1,h(d(1,`(d(h(l(1,`(d(h(i(1,
              h(i(h(h(
            h(i(1,`(h(
          l(d(d(h(d(h(
        h(d(`(h(
      h(i(l(h(h(
    h(i(d(l(l(i(1,l(`(1,h(h(
  h(i(
    d(1,`(d(
    l(i(i(h(d(l(`(1,h(d(h(
    l(i(i(l(l(`(1,l(l(h(d(l(i(1,h(d(h(
    l(i(i(l(l(i(1,h(d(l(d(1,h(d(h(
    l(i(i(l(l(l(h(d(l(l(1,h(d(h(
  h(d(`(h(
l(h(1,h(d(h(
l(d(d(l(d(l(i(

Try the generator code online! ( Try the encoder script online!)
Try the 605B generator code online!
Try the 662B generator code online! ( Try the 662B encoder script online! )
Try the 684B generator code online!
Try the 692B generator code online!
Try the 716B generator code online!
Try the 768B generator code online! ( Try the 768B encoder script online! )
Try the 846B generator code online!
Try the 880B generator code online!
Try the 904B generator code online!

The core part of the code is encoded with `,d,h,i,l for space,1,(,),comma respectively. Other characters &,>,:,P,X are treated as (,comma,(1,11,,1

The actual characters in the quine code,

  • 1 is converted to $
  • `,d,h,i,l are converted to 0,4,8,9,<

The encoded string forms a long long call chain with encoding rules below;

  • Z -> z( e.g. 1 -> d(
  • z -> z(1, e.g. h -> h(1,
\$\endgroup\$
3
\$\begingroup\$

(,) 46114 17682 14022 12123 11403 11183 9947 Chars or \$9947\log_{256}(3)\approx\$1970.7 Bytes

Less than 10,000 Characters!! Still 2000 characters to go before I can fit it in a url :(

((),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),()())(((),(())()),()()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()()())(((),(())()),())(((),(())()),())(((),(())()),())(((),(())()),()())(((),(())()),()())(((),(())()),()())(((),(())()),()())(()(),()()()()()()()())(()(),(()(),,,,(),,()()()()()))((()),()()())(,,,(()()),(),,()())(,,,(()())())(,,,(()())()()()())(,(,,,(()()))(,,,(()())()),,,(),,()()())(,,,(()())())(,(,,,(()()),(),,()()())(,,,(()())())(,,,(()())()()()())(,,,(()()),(),,()())(,,,(()())(),(),,()())(,,,(()()))(,,,(()())(),(),,()())(,,,(()())()()()())((())(),())((())(),((())())(,,,(()())),,(()())(),(((())))(),((())()))(,,,(()())())(((())),((,,,,,()))(((()))))((()),((()))()),,,(()),((())))((()),()()())((()),((()))(),,(()())(((())),,,,(),,(((())))),(()),((())))

let text = "(()(),()()()()()()()())(()(),(()(),,,,(),,()()()()()))((()),()()())(,,,(()()),(),,()())(,,,(()())())(,,,(()())()()()())(,(,,,(()()))(,,,(()())()),,,(),,()()())(,,,(()())())(,(,,,(()()),(),,()()())(,,,(()())())(,,,(()())()()()())(,,,(()()),(),,()())(,,,(()())(),(),,()())(,,,(()()))(,,,(()())(),(),,()())(,,,(()())()()()())((())(),())((())(),((())())(,,,(()())),,(()())(),(((())))(),((())()))(,,,(()())())(((())),((,,,,,()))(((()))))((()),((()))()),,,(()),((())))((()),()()())((()),((()))(),,(()())(((())),,,,(),,(((())))),(()),((())))";
output = "((),()()())";
for (let c of text){
  output += "(((),(())())," + "()".repeat(c=="(" ? 1 : c==")" ? 2 : 3) + ")";
}
output += text;
out1.innerHTML = output.length + " Chars";
out2.innerHTML = output;
<h1 id=out1></h1>
<p id=out2></p>

Like most esolang quines, there is an encoder and decoder. The decoder is shown below:

(()(),()()()()()()()())(()(),(()(),,,,(),,()()()()()))((()),()()())(,,,(()()),(),,()())(,,,(()())())(,,,(()())()()()())(,(,,,(()()))(,,,(()())()),,,(),,()()())(,,,(()())())(,(,,,(()()),(),,()()())(,,,(()())())(,,,(()())()()()())(,,,(()()),(),,()())(,,,(()())(),(),,()())(,,,(()()))(,,,(()())(),(),,()())(,,,(()())()()()())((())(),())((())(),((())())(,,,(()())),,(()())(),(((())))(),((())()))(,,,(()())())(((())),((,,,,,()))(((()))))((()),((()))()),,,(()),((())))((()),()()())((()),((()))(),,(()())(((())),,,,(),,(((())))),(()),((())))

And in pseudo-code:

a is var[1]
b is var[2]
c is var[a]
d is var[a]+1

b=8
b=b*5;
c=3
(str-output b)*2
str-output b+1, b+4
(str-output b, b+1)*3
str-output b+1
while a>/>=c{
  _=(
  (str-output b)*3
  str-output b+1, b+4
  (str-output b)*2
  (str-output b+1)*2
  str-output b
  (str-output b+1)*2
  str-output b+4
  d=1
  while var[c]+1>/>=d{
    d=d+_=(str-output b)
    str-output b+1
  }
  str-output b+1
  var[c] = var[c]+var[while None>/>=1] // while None>/>=1 is 0, var[0] is input, and EOF is -1, so this is equivilent to var[c] = var[c]-1
  c=c+1
  )
}

c=3
while a>/>=c{
  c=c+1
  str-output b+c*c
}

And the encoder is of the format below:
Once: ((),()()()), and for each char in the decoder: (((),(())()),?) with ? being (), ()(), or ()()() depending on whether the char is (, ), or ,, respectively.

Try It Online!
You have to paste the code yourself, the url was to long otherwise.

\$\endgroup\$
3
\$\begingroup\$

Factor, 56 bytes

"%uUSE: formatting dup printf"USE: formatting dup printf

Try it online!

Inspired by fede s.’s answer.

Explanation:

%uUSE: forma…" String with printf-directive %u to print an unparsed value (wrapping string in quotes) at start of string

USE: formatting Import formatting vocabulary to get printf; string is still on stack.

dup Duplicate the string; now there are two copies on the stack.

printf Print the string with its copy as a formatting argument; the copy is wrapped in quotes and inserted at the start due to %u directive.

\$\endgroup\$
3
\$\begingroup\$

ARBLE, 22 16 bytes

(f%f)"(f%%f)%q"

Essentially the lua quine of s="s=%qprint(s:format(s))"print(s:format(s)). Takes the function f%f (which acts as f:format(f)) and then calls it with the format string "(f%%f)%q, where %q escapes the provided argument.

Try it online!

\$\endgroup\$
3
\$\begingroup\$

FALSE, 34 bytes

["'[,34,$!34,'],!"]'[,34,$!34,'],!

Explanation

["'[,34,$!34,'],!"] {quote that prints the program sources}
'[,34, {write `["`; ASCII code for " is used because FALSE has no escaping}
$! {dup the quote, then call}
34,'], {write `"]`}
! {call the quote again}
\$\endgroup\$
4
  • \$\begingroup\$ Note this works the same way as this FALSE quine of the same length \$\endgroup\$
    – noodle man
    Sep 14 at 11:04
  • \$\begingroup\$ @noodleman I see. Is there a good way to order answers by programming language? \$\endgroup\$
    – Luatic
    Sep 14 at 12:36
  • \$\begingroup\$ It’s not exact but if you go to the search bar while on the question you can search inquestion:this false. Unfortunately in the case of FALSE, it’ll also show any answers which include the word false which can be a lot on some challenges. \$\endgroup\$
    – noodle man
    Sep 14 at 15:50
  • \$\begingroup\$ @noodleman thanks, will use this in the future! \$\endgroup\$
    – Luatic
    Sep 14 at 18:59
2
\$\begingroup\$

Java (229 Characters)

class Main{public static void main(String[]args){char q='"';String s="class Main{public static void main(String[]args){char q='%c';String s=%c%s%c;System.out.print(s.format(s,q,q,s,q));}}";System.out.print(s.format(s,q,q,s,q));}}
\$\endgroup\$
2
  • 4
    \$\begingroup\$ You can shorten it by naming your class a one character name (such as q for quine). Also, there is no need for main(String[]args), just do something like main(String[]a) (total savings: 6 chars) \$\endgroup\$
    – Justin
    Dec 11, 2013 at 23:51
  • \$\begingroup\$ @Justin Technically, 12 bytes saving. \$\endgroup\$
    – driima
    Nov 1, 2016 at 8:59
2
\$\begingroup\$

Haskell, 93 68 characters

s="\nmain=putStrLn$\"s=\"++show s++s"
main=putStrLn$"s="++show s++s
\$\endgroup\$
2
\$\begingroup\$

Bash, 67/51 chars

f () 
{ 
    printf "%s\n${!1} $1" "$(local -f ${!1})"
}
f FUNCNAME

And 51 chars:

trap -- 'printf "%s\n:" "$(trap -p DEBUG)"' DEBUG
:
\$\endgroup\$
2
\$\begingroup\$

Zozotez Lisp: 73

((\ (x) (c x (c (c (" ") (c x))))) (" (\ (x) (c x (c (c (" ") (c x)))))))

This requires one of the REPLs. For one bootstrap expression quine I need it to print: 81

((\ (x) (p (c x (c (c (" ") (c x)))))) (" (\ (x) (p (c x (c (c (" ") (c x))))))))

Extended BrainFuck: 68

This uses mostly Brainfuck code except for the store string procedure.

>~"~!<<.[<]>.>+.-<[.>]<[<]>>+.->[.>]"<<.[<]>.>+.-<[.>]<[<]>>+.->[.>]

A 94 byte version that uses more EBF features:

{c|"{q$q.$p(-)}:q:p$q 34+$p|'{c|'&q&c&q|'}'(-)&c"}{q$q.$p(-)}:q:p$q 34+$p|'{c|'&q&c&q|'}'(-)&c
\$\endgroup\$
2
\$\begingroup\$

Mathematica 17 19

ToString[#0][] & []
\$\endgroup\$
1
  • \$\begingroup\$ Why Community Wiki? \$\endgroup\$
    – MD XF
    Jun 12, 2017 at 23:47
2
\$\begingroup\$

Node.js REPL (22)

console.log(RegExp.$1)
\$\endgroup\$
2
  • \$\begingroup\$ ...this abuses the fact that (I guess) the Node REPL internally executes a regex on the received line? I want to upvote because of the cleverness, but on the other hand I don't want to since it relies on extracting its own source code as a string... \$\endgroup\$
    – FireFly
    Aug 22, 2014 at 15:38
  • \$\begingroup\$ You need to specify the Node version this works in, because running in 7.5.0, this prints a single newline. \$\endgroup\$ Jul 16, 2017 at 5:21
2
\$\begingroup\$

Julia, 101 characters

s="s=%c%s%c;@printf %c%s%c 34 s 34 34 s 34";@printf "s=%c%s%c;@printf %c%s%c 34 s 34" 34 s 34 34 s 34

It's the usual format string technique, but unfortunately you can't get the format specification string from a variable in Julia, so I have to include it twice in the code, which blows everything up.

\$\endgroup\$
2
\$\begingroup\$

Burlesque - 1 byte

Technically, this is a quine:

1

Technically, this is also a quine:

{1 2 3}

Pretty much any literal is a quine.

This is also a quine which doesn't use a simple literal:

,#Q2 SH ~- ",#Q" \/ .+ sh

The comma is not necessary if you launch burlesque in no-stdin mode.

\$\endgroup\$
2
\$\begingroup\$

AppleScript, 2 Bytes

1

It's a little cheaty, but it is following the restrictions of a quine. If we don't count the trailing newline, then this solution becomes 1 byte - 1.

Whenever AppleScript has a final executed line of code, it prints the result of the last operation (whatever it is) to the command line.

text

Any class name has the same effect.

\$\endgroup\$
2
\$\begingroup\$

DUP, 51 bytes

0"0.[34,0[$;$][,1+]#]$!%%!"0.[34,0[$;$][,1+]#]$!%%!

Try it here.

Well, DUP quines are possible, just really, really, long. I'll have to golf some more.

\$\endgroup\$
1
7 8
9
10 11
15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.