Hacker News new | ask | show | jobs
by nick0garvey 1206 days ago
I wouldn't say this is the most boring. In Python it is certainly an empty file.

It was interesting to see the author work through the major obstacles one by one when writing a quine. Glad they didn't take the actual boring route!

3 comments

Yes, and if it's about the most minimal non-empty quine pretty sure it would be this:

    s='s=%r;print(s%%s)';print(s%s)
Anyway, let's make it a bit less boring and make it a C/Python polyglot (not relay) quine:

    #include<stdio.h>
    #define len int main(){char*
    #define zip return 0;}
    #if 0
    def printf(f,*a):print(f%a,end=str())
    #endif
    len
    s="#include<stdio.h>%c#define len int main(){char*%c#define zip return 0;}%c#if 0%cdef printf(f,*a):print(f%%a,end=str())%c#endif%clen%cs=%c%s%c;printf(s,10,10,10,10,10,10,10,34,s,34,10);zip%c";printf(s,10,10,10,10,10,10,10,34,s,34,10);zip
Same in C/Ruby:

    #include<stdio.h>
    #define puts(c)void main(){c;putchar(10);}
    #define dup char*
    dup
    s="#include<stdio.h>%c#define puts(c)void main(){c;putchar(10);}%c#define dup char*%cdup%cs=%c%s%c;puts(printf(s,10,10,10,10,34,s,34))";puts(printf(s,10,10,10,10,34,s,34))
Wonder if one can make that shorter.
Yeah. I wish the article talked about "the most boring nonempty quine".
Probably anyone reading this thread knows about this already :-) but that's like the https://en.wikipedia.org/wiki/Interesting_number_paradox
Maybe the empty quine is not boring by virtue of the fact it's not like all of the other quines.
2 is the odd prime for the same reason.
a non-empty quine in python would be `"hello world"`
Just writing a string in a python doesn’t output that string to stdout
yes it does

     $ ~ echo '"Hello world"' > quine.py
     $ ~ cat quine.py
     "Hello world"
     $ ~ python quine.py
     $ ~
Indeed. In C it is also the empty file, though it takes some compiler settings boogaloo to make it work.

See: https://www.ioccc.org/1994/smr.hint